Skip to content
Permalink
Browse files

Issue #144: Move some code out of TExtForm.OnCreate into .DoShow, whe…

…re 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.
  • Loading branch information...
ansgarbecker committed Sep 25, 2019
1 parent 68994a4 commit d446db554ae5b4c382b10cb4ceee5ca6a03202fb
Showing with 23 additions and 5 deletions.
  1. +2 −1 source/apphelpers.pas
  2. +21 −4 source/extra_controls.pas
@@ -369,7 +369,7 @@ TAppSettings = class(TObject)

implementation

uses main;
uses main, extra_controls;



@@ -1869,6 +1869,7 @@ procedure TDBObjectEditor.Init(Obj: TDBObject);
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;
@@ -14,10 +14,13 @@ TExtForm = class(TForm)
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 @@ constructor TExtForm.Create(AOwner: TComponent);
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 @@ constructor TExtForm.Create(AOwner: TComponent);
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

0 comments on commit d446db5

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