Hi,

Attached is a patch that adds two new events to a TSpeedButton.
OnEnter and OnExit  (like TBitBtn has).
This is really handy in the case where you want to have three
different image states. Enabled, Disabled and Hover - a well know
feature in Windows applications.

I know this is not Delphi compatible - so in that case just don't use them.  ;-)
To think of it, I don't know why not every widget has a OnEnter and
OnExit event. They are always handy.


Patch needs to be applied from the root Lazarus directory.

--
Graeme Geldenhuys

There's no place like S34° 03.168'  E018° 49.342'
Index: lcl/include/speedbutton.inc
===================================================================
--- lcl/include/speedbutton.inc	(revision 10987)
+++ lcl/include/speedbutton.inc	(working copy)
@@ -841,6 +841,7 @@
   then begin
     FMouseInControl := True;
     UpdateState(true);
+    if Assigned(FOnEnter) then FOnEnter(Self);
   end;
 end;
 
@@ -859,7 +860,10 @@
   then begin
     FMouseInControl := False;
     if Enabled then
+    begin
       UpdateState(true);
+      if Assigned(FOnExit) then FOnExit(Self);
+    end;
   end;
 end;
 
Index: lcl/buttons.pp
===================================================================
--- lcl/buttons.pp	(revision 10987)
+++ lcl/buttons.pp	(working copy)
@@ -294,6 +294,8 @@
     FLayout: TButtonLayout;
     FMargin: integer;
     FMouseInControl: Boolean;
+    FOnEnter: TNotifyEvent;
+    FOnExit: TNotifyEvent;
     FShortcut: TShortCut;
     FShowAccelChar: boolean;
     FShowCaption: boolean;
@@ -359,6 +361,8 @@
     property ShowCaption: boolean read FShowCaption write SetShowCaption default true;
     property Spacing: integer read FSpacing write SetSpacing default 4;
     property Transparent: Boolean read FTransparent write SetTransparent default true;
+    property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
+    property OnExit: TNotifyEvent read FOnExit write FOnExit;
   end;
 
 
@@ -388,6 +392,8 @@
     property Visible;
     property OnClick;
     property OnDblClick;
+    property OnEnter;
+    property OnExit;
     property OnMouseDown;
     property OnMouseMove;
     property OnMouseUp;

Reply via email to