From d446db554ae5b4c382b10cb4ceee5ca6a03202fb Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 25 Sep 2019 20:14:52 +0200 Subject: [PATCH] Issue #144: Move some code out of TExtForm.OnCreate into .DoShow, where it works for more instances of TEdit, e.g. the database and table filter. Also, let the object editors call this code, as they don't derive from TExtForm. --- source/apphelpers.pas | 3 ++- source/extra_controls.pas | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/source/apphelpers.pas b/source/apphelpers.pas index bd792a02..4275dbc6 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -369,7 +369,7 @@ var implementation -uses main; +uses main, extra_controls; @@ -1869,6 +1869,7 @@ var begin Mainform.ShowStatusMsg(_('Initializing editor ...')); Mainform.LogSQL(Self.ClassName+'.Init, using object "'+Obj.Name+'"', lcDebug); + TExtForm.FixControls(Self); DBObject := TDBObject.Create(Obj.Connection); DBObject.Assign(Obj); Mainform.UpdateEditorTab; diff --git a/source/extra_controls.pas b/source/extra_controls.pas index 88536fc2..646b6d88 100644 --- a/source/extra_controls.pas +++ b/source/extra_controls.pas @@ -14,10 +14,13 @@ type FSizeGrip: TSizeGripXP; function GetHasSizeGrip: Boolean; procedure SetHasSizeGrip(Value: Boolean); + protected + procedure DoShow; override; public constructor Create(AOwner: TComponent); override; procedure InheritFont(AFont: TFont); property HasSizeGrip: Boolean read GetHasSizeGrip write SetHasSizeGrip default False; + class procedure FixControls(FormOrFrame: TScrollingWincontrol); end; // Memo replacement which accepts any line break format TLineNormalizingMemo = class(TMemo) @@ -35,8 +38,6 @@ implementation constructor TExtForm.Create(AOwner: TComponent); var OldImageList: TCustomImageList; - i: Integer; - Cmp: TComponent; begin inherited; @@ -61,8 +62,23 @@ begin TranslateComponent(Self); end; - for i:=0 to ComponentCount-1 do begin - Cmp := Components[i]; +end; + + +procedure TExtForm.DoShow; +begin + FixControls(Self); + inherited; +end; + + +class procedure TExtForm.FixControls(FormOrFrame: TScrollingWincontrol); +var + i: Integer; + Cmp: TComponent; +begin + for i:=0 to FormOrFrame.ComponentCount-1 do begin + Cmp := FormOrFrame.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/ @@ -76,6 +92,7 @@ begin end; if Cmp is TCustomEdit then begin // Support Ctr+Backspace for deleting last word in TEdit and TButtonedEdit + // This did not work in OnCreate, so here's it in OnShow // 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