From 67bff74bc9a198f8be78bcd1c9e136ccfea89d86 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sat, 25 Sep 2010 13:12:35 +0200 Subject: TfpgWidget: adds support for new event, OnDragStartDetected --- src/corelib/fpg_widget.pas | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/fpg_widget.pas b/src/corelib/fpg_widget.pas index 3f5204ed..7a95b92b 100644 --- a/src/corelib/fpg_widget.pas +++ b/src/corelib/fpg_widget.pas @@ -47,6 +47,7 @@ type FOnDragDrop: TfpgDragDropEvent; FOnDragEnter: TfpgDragEnterEvent; FOnDragLeave: TNotifyEvent; + FOnDragStartDetected: TNotifyEvent; FOnEnter: TNotifyEvent; FOnExit: TNotifyEvent; FOnMouseDown: TMouseButtonEvent; @@ -59,6 +60,8 @@ type FOnResize: TNotifyEvent; FOnScreen: boolean; FOnShowHint: THintEvent; + FDragStartPos: TfpgPoint; + FDragActive: boolean; procedure SetActiveWidget(const AValue: TfpgWidget); function IsShowHintStored: boolean; procedure SetFormDesigner(const AValue: TObject); @@ -136,6 +139,7 @@ type { property events } property OnClick: TNotifyEvent read FOnClick write FOnClick; property OnDoubleClick: TMouseButtonEvent read FOnDoubleClick write FOnDoubleClick; + property OnDragStartDetected: TNotifyEvent read FOnDragStartDetected write FOnDragStartDetected; property OnEnter: TNotifyEvent read FOnEnter write FOnEnter; property OnExit: TNotifyEvent read FOnExit write FOnExit; property OnKeyPress: TKeyPressEvent read FOnKeyPress write FOnKeyPress; @@ -428,6 +432,7 @@ begin FBackgroundColor := clWindowBackground; FTextColor := clText1; FAcceptDrops := False; + FDragActive := False; inherited Create(AOwner); @@ -585,6 +590,7 @@ begin case msg.Params.mouse.Buttons of MOUSE_LEFT: begin + 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); end; @@ -611,6 +617,7 @@ var IsDblClick: boolean; begin // writeln('TfpgWidget.MsgMouseUp'); + FDragActive := False; if InDesigner then begin FFormDesigner.Dispatch(msg); @@ -675,6 +682,16 @@ begin Exit; end; + if (msg.Params.mouse.Buttons and MOUSE_LEFT) = MOUSE_LEFT then + begin + if not FDragActive and (FDragStartPos.ManhattanLength(fpgPoint(msg.Params.mouse.x, msg.Params.mouse.y)) > fpgApplication.StartDragDistance) then + begin + FDragActive := True; + if Assigned(OnDragStartDetected) then + OnDragStartDetected(self); + end; + end; + HandleMouseMove(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.Buttons, msg.Params.mouse.shiftstate); if Assigned(OnMouseMove) then OnMouseMove(self, msg.Params.mouse.shiftstate, -- cgit v1.2.3-70-g09d2