Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Rücktaste in cursor links umwandeln (https://www.delphipraxis.net/200811-ruecktaste-cursor-links-umwandeln.html)

TurboMagic 28. Mai 2019 12:28

Rücktaste in cursor links umwandeln
 
Hallo,

in einer Delphi 10.2 VCL Anwendung habe ich gerade versucht das Drücken der
Rücktaste/Backspace Taste zu erkennen und in ein "Cursor Taste links" gedrückt
zu verwandeln.

Delphi-Quellcode:
procedure TMyForm.MyEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if (Key in [vk_Back]) then
    Key := vk_Left;
end;
Nur leider funktioniert das nicht.
Liegt es evtl. daran, dass die Pfeiltasten (und einige weitere) zumindest unter DOS
immer erst ein #0 und dann den Tastencode senden?

Falls ja, wie kann das simuliert werden?
Oder geht es irgendwie anders?

Grüße
TurboMagic

Cashew 28. Mai 2019 12:42

AW: Rücktaste in cursor links umwandeln
 
Hi,

im OnKeyPress Event könnte das ganze wie folgt aussehen:

Delphi-Quellcode:
procedure TMyForm.MyEditKeyPress(Sender: TObject; var Key: Char);
begin
  if (Key = #8) then begin
    Key := #0;
    if (MyEdit.SelStart > 0) then
      MyEdit.SelStart := MyEdit.SelStart-1;
  end;
end;

TurboMagic 28. Mai 2019 21:54

AW: Rücktaste in cursor links umwandeln
 
Danke!


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz