diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-01-20 11:48:57 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-01-20 11:48:57 +0200 |
commit | 439ca504ee40054088bb97088c0e95c8016f5d5d (patch) | |
tree | f3404cbd65b3e80c59b050c30ab33e236aa64a16 /src/corelib | |
parent | 3db3fc8cad32b4d84164b6089db196f955be721a (diff) | |
download | fpGUI-439ca504ee40054088bb97088c0e95c8016f5d5d.tar.xz |
adds extra checks to know when we shouldn't fire the OnClick event
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/fpg_widget.pas | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/fpg_widget.pas b/src/corelib/fpg_widget.pas index ff9dec72..efbf6127 100644 --- a/src/corelib/fpg_widget.pas +++ b/src/corelib/fpg_widget.pas @@ -208,6 +208,7 @@ var uLastClickWidget: TfpgWidget; uLastClickPoint: TPoint; uLastClickTime: DWord; + uMouseDownSourceWidget: TfpgWidget; { widget Left MButton was pressed on } function FindKeyboardFocus: TfpgWidget; @@ -638,6 +639,7 @@ begin case msg.Params.mouse.Buttons of MOUSE_LEFT: begin + uMouseDownSourceWidget := self; FDragStartPos.SetPoint(msg.Params.mouse.x, msg.Params.mouse.y); mb := mbLeft; HandleLMouseDown(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.shiftstate); @@ -704,6 +706,8 @@ begin // The mouse up must still be handled even if we had a double click event. HandleLMouseUp(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.shiftstate); + + uMouseDownSourceWidget := nil; end; MOUSE_RIGHT: @@ -731,7 +735,7 @@ begin Exit; end; - if (msg.Params.mouse.Buttons and MOUSE_LEFT) = MOUSE_LEFT then + if ((msg.Params.mouse.Buttons and MOUSE_LEFT) = MOUSE_LEFT) and (self = uMouseDownSourceWidget) then begin if not FDragActive and (FDragStartPos.ManhattanLength(fpgPoint(msg.Params.mouse.x, msg.Params.mouse.y)) > fpgApplication.StartDragDistance) then begin @@ -1055,7 +1059,7 @@ var r: TfpgRect; begin r.SetRect(0, 0, Width, Height); - if PtInRect(r, Point(x, y)) and FOnClickPending then + if PtInRect(r, Point(x, y)) and FOnClickPending and (self = uMouseDownSourceWidget) then begin if Assigned(FOnClick) then FOnClick(self); |