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