diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/fpg_widget.pas | 7 | ||||
-rw-r--r-- | src/gui/fpg_button.pas | 11 |
2 files changed, 12 insertions, 6 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; diff --git a/src/gui/fpg_button.pas b/src/gui/fpg_button.pas index fbca006f..cc9866c3 100644 --- a/src/gui/fpg_button.pas +++ b/src/gui/fpg_button.pas @@ -664,7 +664,7 @@ begin FDown := False; RePaint; fpgApplication.ProcessMessages; - if PtInRect(r, Point(x, y)) then + if PtInRect(r, Point(x, y)) and FOnClickPending then Click; end; end @@ -675,7 +675,7 @@ begin FDown := False; RePaint; fpgApplication.ProcessMessages; - if PtInRect(r, Point(x, y)) then + if PtInRect(r, Point(x, y)) and FOnClickPending then Click; end; end; @@ -785,8 +785,11 @@ begin if Assigned(FCommand) then // ICommand takes preference to OnClick FCommand.Execute - else if Assigned(OnClick) then - OnClick(self); + else + begin + if Assigned(OnClick) then + OnClick(self); + end; end; function TfpgBaseButton.GetCommand: ICommand; |