summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2010-09-25 13:12:35 +0200
committerGraeme Geldenhuys <graemeg@gmail.com>2010-09-25 13:12:35 +0200
commit67bff74bc9a198f8be78bcd1c9e136ccfea89d86 (patch)
treea04213a3f1cf146ffdafee8a9cda6c2990e00f1a /src/corelib
parent7c1b509760c2920a1d80d855bb68094001918624 (diff)
downloadfpGUI-67bff74bc9a198f8be78bcd1c9e136ccfea89d86.tar.xz
TfpgWidget: adds support for new event, OnDragStartDetected
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpg_widget.pas17
1 files changed, 17 insertions, 0 deletions
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,