Using your Editor2 demo, try this on Android (it does occur on iOS, but nowhere nearly as bad).
Type a few words, but leave the caret at the last word you typed (no space). Now type 3 more non-space chars and then start tapping the Undo more than 3 times. Watch the behavior to what gets undone. You should see the last word eventually get undone as expected, but then it starts coming back. It will do that 3 times before it starts undoing the other words you typed (but may repeat the same behavior). The undo buffer seems to have gone wonky (technical term).
If I have text already loaded, and I place the caret at the end of a word and tap a few chars, the undo will undo the existing word but will come back as you keep hitting the undo, at least on Android (don't see that on iOS).
TRichViewFMX v23
Delphi 12.3
Android and iOS keyboard issue with undo
-
- Site Admin
- Posts: 17909
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Android and iOS keyboard issue with undo
I need several days to complete the current work and check this issue. Sorry for the delay.
-
- Posts: 64
- Joined: Sun May 25, 2025 6:41 pm
Re: Android and iOS keyboard issue with undo
No problem... this one is probably not urgent. It was just very weird that a customer might run into, so thought you might want to check it out. On android it did some bad stuff to a table, like delete it, or duplicate some text around the table, not on iOS though.
-
- Site Admin
- Posts: 17909
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Android and iOS keyboard issue with undo
Unfortunately, this is not an editor's bug.
Delphi 12 implements text input on Android in a crazy way.
The native Android way (as was implemented in older versions of Delphi) is to replace the changed text with a new one when a new character is typed.
Delphi 12 instead emulates keystrokes. When the user types a character, this first deletes the current word (simulating multiple Backspace/Delete presses), then enters the changed word (with a new character), character by character.
Everything works fine, but all operations are undone one by one, which causes the wild effect you described.
I'll see if I can do something about it. But I'm not sure about the next update.
Delphi 12 implements text input on Android in a crazy way.
The native Android way (as was implemented in older versions of Delphi) is to replace the changed text with a new one when a new character is typed.
Delphi 12 instead emulates keystrokes. When the user types a character, this first deletes the current word (simulating multiple Backspace/Delete presses), then enters the changed word (with a new character), character by character.
Everything works fine, but all operations are undone one by one, which causes the wild effect you described.
I'll see if I can do something about it. But I'm not sure about the next update.
-
- Site Admin
- Posts: 17909
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Android and iOS keyboard issue with undo
It looks like I found a workaround.
The obvious solution is to intercept beginning and ending of text changing on typing to initialize and finalize grouping of undo operations.
Unfortunately, FireMonkey Android services do not allow to do it.
So, I tried an alternative approach: using a timer to group all operations that immediately follow Backscape or Delete key press. After that, undo works as expected.
This solution will be included in the next update.
The bad side is that a single character press generates multiple entries in the undo buffer, which wastes memory. I will try to optimize it in one of the next updates.
The obvious solution is to intercept beginning and ending of text changing on typing to initialize and finalize grouping of undo operations.
Unfortunately, FireMonkey Android services do not allow to do it.
So, I tried an alternative approach: using a timer to group all operations that immediately follow Backscape or Delete key press. After that, undo works as expected.
This solution will be included in the next update.
The bad side is that a single character press generates multiple entries in the undo buffer, which wastes memory. I will try to optimize it in one of the next updates.
-
- Posts: 64
- Joined: Sun May 25, 2025 6:41 pm
Re: Android and iOS keyboard issue with undo
Nobody has mentioned this odd behavior yet. I have found they usually undo an insert of a paragraph or so of text, or just backspace to correct spelling rather than use undo. I just happened upon it by accident as I was testing, so implement or not this get-around as you feel appropriate.
Just watch, Embarcadero will change keyboard functionality once again and mess up your get-around (maybe in the upcoming v13). They already have a huge issue with dictation on iOS. Dictation into a TMemo (and TRichView for that matter) will loop a backspace delete as you dictate, deleting existing text. This started with iOS 17+ I found the backspace delete in Delphi and commented it out for grins to stop it, but of course the virtual keyboard backspace key then doesn't work. It appears to be called externally, such as from iOS. Not an issue with Android.
Just watch, Embarcadero will change keyboard functionality once again and mess up your get-around (maybe in the upcoming v13). They already have a huge issue with dictation on iOS. Dictation into a TMemo (and TRichView for that matter) will loop a backspace delete as you dictate, deleting existing text. This started with iOS 17+ I found the backspace delete in Delphi and commented it out for grins to stop it, but of course the virtual keyboard backspace key then doesn't work. It appears to be called externally, such as from iOS. Not an issue with Android.