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.

This commit is contained in:
Ansgar Becker
2019-09-25 20:14:52 +02:00
parent 68994a4e4d
commit d446db554a
2 changed files with 23 additions and 5 deletions

View File

@ -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;

View File

@ -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