Simulate a backspace key

General TRichView support forum. Please post your questions here
Post Reply
whisper1980
Posts: 8
Joined: Sun May 25, 2025 6:41 pm

Simulate a backspace key

Post by whisper1980 »

Still evaluating TRichView, but is there a way on mobile to simulate a backspace key (from an on-screen button)? Simulating the Enter key was easy, but I can't figure out how to simulate a virtual keyboard's backspace key.

Some background...
On a phone, having the keyboard popup whenever the user taps into the editor is not desired mostly due to limited real estate, so I have a kbd key button on the toolbar so they can open it whenever they need it. However, they like having two buttons on the toolbar: Enter and Backspace, that they can use without having to bring up the keyboard just to do either of those two (the kbd popup frequently blocks what they want to modify). I tried using an HTML editor for the mobile app, but it is too incompatible with our Windows app to convert between HTML and RTF, but that editor has a delete previous character function. Anyway, the data collection app on mobile has an unlimited number of what I call RapidRemarks that inspectors can use to populate their findings. So the Enter key button is extremely helpful for being able to add spacing to accommodate the RapidRemark. The backspace is also very helpful if they want to remove some pre-existing text or to remove empty lines without having to select>delete.
Sergey Tkachenko
Site Admin
Posts: 17842
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Simulate a backspace key

Post by Sergey Tkachenko »

In VCL version, you can use SendMessage:

SendMessage(RichViewEdit1.TopLevelEditor.Handle, WM_KEYDOWN, VK_BACK, 0)
whisper1980
Posts: 8
Joined: Sun May 25, 2025 6:41 pm

Re: Simulate a backspace key

Post by whisper1980 »

Unfortunately, I'm using FMX on Android and iOS.
Sergey Tkachenko
Site Admin
Posts: 17842
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Simulate a backspace key

Post by Sergey Tkachenko »

TCustomRichViewEdit has a method for processing Backspace:

Code: Select all

procedure OnBackSpacePress(Ctrl: Boolean);
But this method is protected.
You can try to call it in this way:

Code: Select all

type
  TCustomRichViewEditHack = class (TCustomRichViewEdit)
  end;
...
  TCustomRichViewEditHack(RichViewEdit1.TopLevelEditor).OnBackSpacePress(False);
But it needs to be tested how this hack works on mobile platforms.
I hope you use Delphi 12.x.
In earlier versions of Delphi, keyboard input in Android was handled by changing text instead of processing keys.
Post Reply