Skip to content

Commit

Permalink
Issue #144: Prefer emptying selection in TCustomEdit's via EM_REPLACE…
Browse files Browse the repository at this point in the history
…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 f874c80
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/main.pas
Expand Up @@ -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*$';
Expand All @@ -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
Expand Down

0 comments on commit f874c80

Please sign in to comment.