Issue #144: make Ctrl+Backspace delete the last word of TEdit and TButtonedEdit in any TExtForm

This commit is contained in:
Ansgar Becker
2019-09-25 17:40:03 +02:00
parent 67967b411f
commit 68994a4e4d

View File

@@ -4,7 +4,8 @@ interface
uses
Classes, SysUtils, Forms, Windows, Messages, System.Types, StdCtrls, Clipbrd,
SizeGrip, apphelpers, Vcl.Graphics, Vcl.Dialogs, gnugettext, Vcl.ImgList, Vcl.ComCtrls;
SizeGrip, apphelpers, Vcl.Graphics, Vcl.Dialogs, gnugettext, Vcl.ImgList, Vcl.ComCtrls,
ShLwApi, Vcl.ExtCtrls;
type
// Form with a sizegrip in the lower right corner, without the need for a statusbar
@@ -59,18 +60,27 @@ begin
end else begin
TranslateComponent(Self);
end;
// Work around broken dropdown (tool)button on Wine after translation:
// https://sourceforge.net/p/dxgettext/bugs/80/
for i:=0 to ComponentCount-1 do begin
Cmp := Components[i];
if (Cmp is TButton) and (TButton(Cmp).Style = bsSplitButton) then begin
// Work around broken dropdown (tool)button on Wine after translation:
// https://sourceforge.net/p/dxgettext/bugs/80/
TButton(Cmp).Style := bsPushButton;
TButton(Cmp).Style := bsSplitButton;
end;
if (Cmp is TToolButton) and (TToolButton(Cmp).Style = tbsDropDown) then begin
// similar fix as above
TToolButton(Cmp).Style := tbsButton;
TToolButton(Cmp).Style := tbsDropDown;
end;
if Cmp is TCustomEdit then begin
// Support Ctr+Backspace for deleting last word in TEdit and TButtonedEdit
// See https://stackoverflow.com/questions/10305634/ctrlbackspace-in-delphi-controls
// See issue #144
// Todo: find a way to fix TComboBox, for which this hack does nothing
SHAutoComplete(TCustomEdit(Cmp).Handle, SHACF_AUTOAPPEND_FORCE_ON or SHACF_AUTOSUGGEST_FORCE_ON);
end;
end;
end;