0

In a 32-bit VCL Application in Windows 10 in Delphi 11 Alexandria, I have a TRichEdit control. (Please note that the TRichEdit class in Delphi 11 Alexandria differs from previous Delphi versions).

Now, it seems that TRichEdit has a BUILT-IN Paste command and Shortcut: When I press CTRL+V, then the clipboard content gets inserted (image, formatted text).

So far, so good. But to allow the user to paste PLAIN TEXT (i.e., unformatted text) explicitly - even if there is formatted text on the clipboard, I have created a "Paste Plain Text" menu item command:

procedure TForm1.menuitemPastePlainTextClick(Sender: TObject);
begin
  var ClipboardPlainText := Vcl.Clipbrd.Clipboard.AsText;
  RichEdit1.SelText := ClipboardPlainText;
end;

I have assigned the shortcut SHIFT+CTRL+V to this command. (This shortcut is widely used among many applications for pasting unformatted text). However, when I type SHIFT+CTRL+V in RichEdit1, the FORMATTED text from the clipboard is pasted! Obviously, a BUILT-IN SHIFT+CTRL+V command in RichEdit1 has a higher priority than my custom shortcut.

So, how can I get rid of the built-in SHIFT+CTRL+V command in RichEdit1 to paste Plain Text?

user1580348
  • 5,721
  • 4
  • 43
  • 105
  • I am unable to reproduce the issue in Delphi 10.4, so it seems like this is a new issue in the new `TRichEdit` of Delphi 11. I think I consider this to be a bug. – Andreas Rejbrand Feb 08 '22 at 11:57
  • "Obviously, a BUILT-IN SHIFT+CTRL+V command in RichEdit1 has a higher priority than my custom shortcut." Are you sure? What does this command do? My guess would be that the Rich Edit control says "Ah, Ctrl+V is pressed!" when you press Shift+Ctrl+V. – Andreas Rejbrand Feb 08 '22 at 12:02
  • That's my guess too. – user1580348 Feb 08 '22 at 12:57
  • Well, I'll have a look at this the next time I have access to a Delphi 11 installation. – Andreas Rejbrand Feb 08 '22 at 18:10
  • After further tests, for reasons unknown to me, the shortcut SHIFT+CTRL+V now takes precedence over the built-in shortcut: Now, when I press SHIFT+CTRL+V, the `menuitemPastePlainTextClick` handler gets executed, and the Plain Text is inserted - even if there is formatted text on the clipboard. – user1580348 Feb 08 '22 at 20:44
  • That's the behaviour I'd expect. – Andreas Rejbrand Feb 08 '22 at 20:46

0 Answers0