StringReplace behavoir on iOS

  

I have a TEdit box and in it’s KeyUp event i am replacing any occurrence of “-” with a blank, “”. When i run on Win32 it works exactly as i expect – anytime i type the – key it shows up briefly and then is removed.

When i run on iOS and repeatedly press the – key i get the result of deleting the last character in the Edit box every other time i press -. The exception is the 2nd and 3rd presses in which i delete the last character both times. It should just be removing the -.

e.g. If i start out with 123456 in the Edit and start pressing just the minus key i get what you see in this gif below:

In tabular form the results are these:

void __fastcall TForm1::EditConstantKeyUp(TObject *Sender, WORD &Key, System::WideChar &KeyChar,
TShiftState Shift)
{
if (KeyChar == 45) { // minus key pressed (ascii code for that key is 45)
EditConstant->Text = StringReplace(EditConstant->Text, “-“, “”, TReplaceFlags() << rfReplaceAll);
}

What fundamental thing am i missing here? I’m working in Rad Studio 10.3.2 using C++ Builder.

Comments are closed.