Skip to content
Permalink
Browse files

Issue #144: Prefer emptying selection in TCustomEdit's via EM_REPLACE…

…SEL message, which we can prepare to support undo. Unfortunately, not so in TComboBox, which does nothing then.
  • Loading branch information...
ansgarbecker committed Oct 19, 2019
1 parent cf68103 commit f874c80626ac35e10b8d5dde10c16ad2ba9accb0
Showing with 3 additions and 2 deletions.
  1. +3 −2 source/main.pas
@@ -12774,7 +12774,7 @@ procedure TMainForm.ApplicationEvents1ShortCut(var Msg: TWMKey;
TextMatches: Boolean;
begin
// Support for Ctrl+Backspace shortcut in edit + combobox controls
if (Msg.CharCode = 8) and (GetKeyState(VK_CONTROL) < 0) then begin
if (Msg.CharCode = VK_BACK) and (GetKeyState(VK_CONTROL) < 0) then begin
SendingControl := Screen.ActiveControl;
rx := TRegExpr.Create;
rx.Expression := '\b\W*\w+\W*$';
@@ -12785,7 +12785,8 @@ procedure TMainForm.ApplicationEvents1ShortCut(var Msg: TWMKey;
if TextMatches then begin
Edit.SelStart := rx.MatchPos[0]-1;
Edit.SelLength := LastStart - Edit.SelStart;
Edit.SelText := '';
// wParam=1 supports undo, in contrast to setting Edit.SelText
SendMessage(Edit.Handle, EM_REPLACESEL, 1, LongInt(PChar('')));
end;
Handled := True;
end

0 comments on commit f874c80

Please sign in to comment.
You can’t perform that action at this time.