mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 07:21:34 +02:00
implemented TButtonControl.UseOnChange
git-svn-id: trunk@3961 -
This commit is contained in:
parent
30f6586797
commit
bf371c66ab
@ -21,6 +21,11 @@ begin
|
||||
// or not TButtonActionLink(ActionLink).IsCheckedLinked;
|
||||
end;
|
||||
|
||||
function TButtonControl.UseOnChangeIsStored: boolean;
|
||||
begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TButtonControl.GetChecked: Boolean;
|
||||
begin
|
||||
GetChecked := False;
|
||||
@ -31,9 +36,24 @@ begin
|
||||
// this is done in the overriden methods
|
||||
end;
|
||||
|
||||
procedure TButtonControl.DoOnChange;
|
||||
begin
|
||||
if Checked=fLastCheckedOnChange then exit;
|
||||
fLastCheckedOnChange:=Checked;
|
||||
if csLoading in ComponentState then exit;
|
||||
if UseOnChange and Assigned(OnChange) then OnChange(Self);
|
||||
end;
|
||||
|
||||
procedure TButtonControl.Click;
|
||||
begin
|
||||
DoOnChange;
|
||||
inherited Click;
|
||||
end;
|
||||
|
||||
constructor TButtonControl.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
FUseOnChange:=DefaultButtonControlUseOnChange;
|
||||
ControlStyle:=ControlStyle-csMultiClicks-[csAcceptsControls];
|
||||
end;
|
||||
|
||||
|
@ -133,7 +133,11 @@ begin
|
||||
if FState <> OldState then
|
||||
begin
|
||||
ApplyChanges;
|
||||
if not ClicksDisabled then Click;
|
||||
if UseOnChange then begin
|
||||
DoOnChange;
|
||||
end else begin
|
||||
if not ClicksDisabled then Click;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -163,15 +167,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomCheckBox.Click;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomCheckBox.Click;
|
||||
begin
|
||||
inherited Changed;
|
||||
inherited Click;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomCheckBox.SetText(const Value: TCaption);
|
||||
------------------------------------------------------------------------------}
|
||||
@ -193,8 +188,14 @@ begin
|
||||
CNSendMessage(LM_SETSHORTCUT, Self, @FShortcut);
|
||||
end;
|
||||
end;
|
||||
|
||||
// included by stdctrls.pp
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.13 2003/03/25 16:56:57 mattias
|
||||
implemented TButtonControl.UseOnChange
|
||||
|
||||
Revision 1.12 2003/03/25 16:29:53 mattias
|
||||
fixed sending TButtonControl.OnClick on every change
|
||||
|
||||
|
@ -610,12 +610,21 @@ type
|
||||
TButtonControl = class(TWinControl)
|
||||
private
|
||||
FClicksDisabled: Boolean;
|
||||
FOnChange: TNotifyEvent;
|
||||
FUseOnChange: boolean;
|
||||
function IsCheckedStored: boolean;
|
||||
function UseOnChangeIsStored: boolean;
|
||||
protected
|
||||
fLastCheckedOnChange: boolean;
|
||||
function GetChecked: Boolean; virtual;
|
||||
procedure SetChecked(Value: Boolean); virtual;
|
||||
procedure DoOnChange; virtual;
|
||||
procedure Click; override;
|
||||
protected
|
||||
property Checked: Boolean read GetChecked write SetChecked stored IsCheckedStored default False;
|
||||
property ClicksDisabled: Boolean read FClicksDisabled write FClicksDisabled;
|
||||
property UseOnChange: boolean read FUseOnChange write FUseOnChange stored UseOnChangeIsStored;
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
end;
|
||||
@ -643,15 +652,11 @@ type
|
||||
procedure SetChecked(Value: Boolean); override;
|
||||
procedure SetText(const Value: TCaption); override;
|
||||
procedure ApplyChanges; virtual;
|
||||
procedure Click; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
public
|
||||
property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed;
|
||||
property State: TCheckBoxState read GetState write SetState;
|
||||
published
|
||||
property TabOrder;
|
||||
property TabStop;
|
||||
end;
|
||||
|
||||
{$IFNDef NewCheckBox}
|
||||
@ -663,33 +668,35 @@ type
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
published
|
||||
property AutoSize;
|
||||
property AllowGrayed;
|
||||
property Anchors;
|
||||
property AutoSize;
|
||||
property Caption;
|
||||
property Checked;
|
||||
property State;
|
||||
property Visible;
|
||||
property Enabled;
|
||||
property OnEnter;
|
||||
property OnExit;
|
||||
property DragCursor;
|
||||
property DragKind;
|
||||
property DragMode;
|
||||
property Enabled;
|
||||
property Hint;
|
||||
property ParentShowHint;
|
||||
property PopupMenu;
|
||||
property ShowHint;
|
||||
property TabOrder;
|
||||
property TabStop;
|
||||
property OnChange;
|
||||
property OnClick;
|
||||
property OnDragDrop;
|
||||
property OnDragOver;
|
||||
property OnEndDrag;
|
||||
property OnEnter;
|
||||
property OnExit;
|
||||
property OnMouseDown;
|
||||
property OnMouseMove;
|
||||
property OnMouseUp;
|
||||
property OnStartDrag;
|
||||
property ParentShowHint;
|
||||
property PopupMenu;
|
||||
property ShowHint;
|
||||
property State;
|
||||
property TabOrder;
|
||||
property TabStop;
|
||||
property UseOnChange;
|
||||
property Visible;
|
||||
end;
|
||||
{$Else NewCheckBox}
|
||||
// new checkbox
|
||||
@ -912,6 +919,9 @@ type
|
||||
property OnMouseMove;
|
||||
property OnMouseUp;
|
||||
end;
|
||||
|
||||
var
|
||||
DefaultButtonControlUseOnChange: boolean;
|
||||
|
||||
implementation
|
||||
|
||||
@ -1399,11 +1409,17 @@ end;
|
||||
|
||||
{$I customstatictext.inc}
|
||||
|
||||
initialization
|
||||
DefaultButtonControlUseOnChange:=false;
|
||||
|
||||
end.
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.84 2003/03/25 16:56:57 mattias
|
||||
implemented TButtonControl.UseOnChange
|
||||
|
||||
Revision 1.83 2003/03/25 16:29:53 mattias
|
||||
fixed sending TButtonControl.OnClick on every change
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user