summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-25 14:53:44 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-25 14:53:44 +0200
commitbf8a6f279217408bd21b9bfbadd8416c2b850cb8 (patch)
tree86b1b842de8d6de71ffe1b9c0280233d96dedbfe /src/corelib
parentd1b0ae55c3a2a70737f298a61952bacb2d8a021e (diff)
downloadfpGUI-bf8a6f279217408bd21b9bfbadd8416c2b850cb8.tar.xz
Improved event firing of OnDoubleClick and OnClick
* Single click produces one OnClick event * On a Double Click in produces a OnClick, then a OnDoubleClick event. Old behaviour used to procuder yet another OnClick at the end. This is not needed. * OnMouseDown and OnMouseUp events behaviour has not changed. The reason we introduce the FOnClickPending instead of fully handling the events in TfpgWidget.MsgMouseUp is because a TfpgButton has slightly different behavior (eg: When clicking on a button, keep mouse down, and move mouse out of button rectangle, then an OnClick must not fire.) The extra FOnClickPending allows us to toggle this behaviour of HandleLButtonUp (which normally fires the OnClick event)
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpg_widget.pas7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/fpg_widget.pas b/src/corelib/fpg_widget.pas
index f0c7f514..2afb667a 100644
--- a/src/corelib/fpg_widget.pas
+++ b/src/corelib/fpg_widget.pas
@@ -99,6 +99,7 @@ type
FBackgroundColor: TfpgColor;
FTextColor: TfpgColor;
FIsContainer: Boolean;
+ FOnClickPending: Boolean;
procedure SetAcceptDrops(const AValue: boolean); virtual;
function GetOnShowHint: THintEvent; virtual;
procedure SetOnShowHint(const AValue: THintEvent); virtual;
@@ -470,6 +471,7 @@ begin
FTextColor := clText1;
FAcceptDrops := False;
FDragActive := False;
+ FOnClickPending := False;
inherited Create(AOwner);
@@ -670,6 +672,7 @@ begin
case msg.Params.mouse.Buttons of
MOUSE_LEFT:
begin
+ FOnClickPending := True;
mb := mbLeft;
if uLastClickWidget = self then
IsDblClick := ((fpgGetTickCount - uLastClickTime) <= DOUBLECLICK_MS)
@@ -683,7 +686,7 @@ begin
uLastClickTime := fpgGetTickCount;
if IsDblClick then
begin
-
+ FOnClickPending := False; { When Double Click occurs we don't want single click }
HandleDoubleClick(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.Buttons, msg.Params.mouse.shiftstate);
if Assigned(FOnDoubleClick) then
FOnDoubleClick(self, mb, msg.Params.mouse.shiftstate,
@@ -1032,7 +1035,7 @@ end;
procedure TfpgWidget.HandleLMouseUp(x, y: integer; shiftstate: TShiftState);
begin
- if Assigned(FOnClick) then
+ if FOnClickPending and Assigned(FOnClick) then
FOnClick(self);
end;