mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 20:19:16 +02:00
LCL: editbtn: deprecate/remove UseFormActivate
git-svn-id: trunk@54192 -
This commit is contained in:
parent
0da26ddcc1
commit
b5e203e374
@ -202,17 +202,13 @@ type
|
|||||||
fFilter: string;
|
fFilter: string;
|
||||||
fIdleConnected: Boolean;
|
fIdleConnected: Boolean;
|
||||||
fSortData: Boolean; // Data needs to be sorted.
|
fSortData: Boolean; // Data needs to be sorted.
|
||||||
fUseFormActivate: Boolean;
|
|
||||||
fIsFirstSetFormActivate: Boolean;
|
fIsFirstSetFormActivate: Boolean;
|
||||||
fJustActivated: Boolean;
|
|
||||||
fParentForm: TForm;
|
|
||||||
fOnAfterFilter: TNotifyEvent;
|
fOnAfterFilter: TNotifyEvent;
|
||||||
|
function GetUseFormActivate: Boolean;
|
||||||
procedure SetFilter(const AValue: string);
|
procedure SetFilter(const AValue: string);
|
||||||
procedure SetIdleConnected(const AValue: Boolean);
|
procedure SetIdleConnected(const AValue: Boolean);
|
||||||
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||||
procedure SetUseFormActivate(AValue: Boolean);
|
procedure SetUseFormActivate(AValue: Boolean);
|
||||||
procedure FormActivate(Sender: TObject); // Connects to owning form.
|
|
||||||
procedure FormDeactivate(Sender: TObject);
|
|
||||||
function IsTextHintStored: Boolean;
|
function IsTextHintStored: Boolean;
|
||||||
protected
|
protected
|
||||||
fNeedUpdate: Boolean;
|
fNeedUpdate: Boolean;
|
||||||
@ -227,8 +223,6 @@ type
|
|||||||
const ItemData: Pointer): Boolean; virtual;
|
const ItemData: Pointer): Boolean; virtual;
|
||||||
procedure EditKeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure EditKeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure EditChange; override;
|
procedure EditChange; override;
|
||||||
procedure EditEnter; override;
|
|
||||||
procedure EditExit; override;
|
|
||||||
procedure ButtonClick; override;
|
procedure ButtonClick; override;
|
||||||
procedure SortAndFilter; virtual; abstract;
|
procedure SortAndFilter; virtual; abstract;
|
||||||
procedure ApplyFilter(Immediately: Boolean = False);
|
procedure ApplyFilter(Immediately: Boolean = False);
|
||||||
@ -260,7 +254,7 @@ type
|
|||||||
deprecated 'Use OnFilterItemEx with a caption parameter instead.';
|
deprecated 'Use OnFilterItemEx with a caption parameter instead.';
|
||||||
property OnFilterItemEx: TFilterItemExEvent read fOnFilterItemEx write fOnFilterItemEx;
|
property OnFilterItemEx: TFilterItemExEvent read fOnFilterItemEx write fOnFilterItemEx;
|
||||||
property OnCheckItem: TCheckItemEvent read fOnCheckItem write fOnCheckItem;
|
property OnCheckItem: TCheckItemEvent read fOnCheckItem write fOnCheckItem;
|
||||||
property UseFormActivate: Boolean read fUseFormActivate write SetUseFormActivate default False;
|
property UseFormActivate: Boolean read GetUseFormActivate write SetUseFormActivate stored False; deprecated 'Will be removed after 1.8 release.';
|
||||||
// TEditButton properties.
|
// TEditButton properties.
|
||||||
property ButtonCaption;
|
property ButtonCaption;
|
||||||
property ButtonCursor;
|
property ButtonCursor;
|
||||||
@ -1155,66 +1149,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomControlFilterEdit.SetUseFormActivate(AValue: Boolean);
|
procedure TCustomControlFilterEdit.SetUseFormActivate(AValue: Boolean);
|
||||||
var
|
|
||||||
c: TWinControl;
|
|
||||||
begin
|
begin
|
||||||
if fUseFormActivate=AValue then Exit;
|
// Remove after 1.8
|
||||||
fUseFormActivate:=AValue;
|
|
||||||
c:=Parent;
|
|
||||||
// Find the parent form
|
|
||||||
while Assigned(c) and not (c is TForm) do
|
|
||||||
c:=c.Parent;
|
|
||||||
// Found: set or remove Activate and Deactivate handlers
|
|
||||||
if c is TForm then begin
|
|
||||||
fParentForm:=TForm(c);
|
|
||||||
if AValue then begin // Set handlers
|
|
||||||
if fIsFirstSetFormActivate then begin
|
|
||||||
if Assigned(fParentForm.OnActivate) or Assigned(fParentForm.OnDeactivate) then
|
|
||||||
raise Exception.Create('TCustomControlFilterEdit.SetUseFormActivate:'+
|
|
||||||
' OnActivate handler already set in parent form');
|
|
||||||
fIsFirstSetFormActivate:=False;
|
|
||||||
end;
|
|
||||||
fParentForm.OnActivate:=@FormActivate;
|
|
||||||
fParentForm.OnDeactivate:=@FormDeactivate;
|
|
||||||
end
|
|
||||||
else begin // Remove handlers
|
|
||||||
fParentForm.OnActivate:=nil;
|
|
||||||
fParentForm.OnDeactivate:=nil;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise Exception.Create('TCustomControlFilterEdit.SetUseFormActivate: This control'+
|
|
||||||
' has no TForm in the parent chain. You should disable UseFormActivate.');
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomControlFilterEdit.FormActivate(Sender: TObject);
|
|
||||||
begin
|
|
||||||
fJustActivated := (fParentForm.ActiveControl=Self.Edit) or Focused or Edit.Focused;
|
|
||||||
if fJustActivated then
|
|
||||||
Edit.DoEnter;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomControlFilterEdit.FormDeactivate(Sender: TObject);
|
|
||||||
begin
|
|
||||||
fJustActivated:=False;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomControlFilterEdit.SetFilter(const AValue: string);
|
procedure TCustomControlFilterEdit.SetFilter(const AValue: string);
|
||||||
var
|
|
||||||
NewValue: String;
|
|
||||||
UseHintText: Boolean;
|
|
||||||
begin
|
begin
|
||||||
UseHintText := (TextHint<>'') and (AValue=TextHint);
|
if Text=AValue then
|
||||||
if UseHintText then
|
Exit;
|
||||||
NewValue:=''
|
|
||||||
else
|
Text:=AValue;
|
||||||
NewValue:=AValue;
|
|
||||||
Button.Enabled:=NewValue<>'';
|
|
||||||
if (not UseHintText) or Focused or fJustActivated or (csDesigning in ComponentState)
|
|
||||||
then
|
|
||||||
Text:=NewValue;
|
|
||||||
if fFilter=NewValue then exit;
|
|
||||||
fFilter:=NewValue;
|
|
||||||
ApplyFilter;
|
ApplyFilter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1266,22 +1210,8 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomControlFilterEdit.EditEnter;
|
|
||||||
begin
|
|
||||||
// inherited;
|
|
||||||
fJustActivated:=False;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomControlFilterEdit.EditExit;
|
|
||||||
begin
|
|
||||||
fJustActivated:=False;
|
|
||||||
Filter:=Text;
|
|
||||||
// inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomControlFilterEdit.ButtonClick;
|
procedure TCustomControlFilterEdit.ButtonClick;
|
||||||
begin
|
begin
|
||||||
fJustActivated:=False;
|
|
||||||
Text:='';
|
Text:='';
|
||||||
Filter:='';
|
Filter:='';
|
||||||
if FocusOnButtonClick then Edit.SetFocus; //don't SelectAll here
|
if FocusOnButtonClick then Edit.SetFocus; //don't SelectAll here
|
||||||
@ -1336,6 +1266,11 @@ begin
|
|||||||
Result := ResBtnListFilter;
|
Result := ResBtnListFilter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomControlFilterEdit.GetUseFormActivate: Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFileNameEdit }
|
{ TFileNameEdit }
|
||||||
|
|
||||||
constructor TFileNameEdit.Create(AOwner: TComponent);
|
constructor TFileNameEdit.Create(AOwner: TComponent);
|
||||||
|
Loading…
Reference in New Issue
Block a user