mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-27 05:01:56 +01:00
carbon: use unified multiclick mouse message handling
git-svn-id: trunk@51736 -
This commit is contained in:
parent
7b141be77b
commit
95b3e6fd5c
@ -404,8 +404,10 @@ var SavedMouseUpMsg: TLMMouse;
|
|||||||
var PostponedDownMsg: TLMMouse;
|
var PostponedDownMsg: TLMMouse;
|
||||||
var PostponedDown: Boolean;
|
var PostponedDown: Boolean;
|
||||||
|
|
||||||
|
// Stores last mouse info for multiple clicks
|
||||||
|
var LastMouse: TLastMouseInfo;
|
||||||
// Stores last mouse pos to call mouse move only when it really has changed
|
// Stores last mouse pos to call mouse move only when it really has changed
|
||||||
var LastMousePos: TPoint;
|
var LastMousePos: TPoint; // in client coordinates
|
||||||
|
|
||||||
{$I carbonprivatecommon.inc}
|
{$I carbonprivatecommon.inc}
|
||||||
{$I carbonprivatecontrol.inc}
|
{$I carbonprivatecontrol.inc}
|
||||||
|
|||||||
@ -206,8 +206,6 @@ end;
|
|||||||
function CarbonCommon_Track(ANextHandler: EventHandlerCallRef;
|
function CarbonCommon_Track(ANextHandler: EventHandlerCallRef;
|
||||||
AEvent: EventRef;
|
AEvent: EventRef;
|
||||||
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
||||||
const
|
|
||||||
MSGKIND: array[1..3] of Integer = (LM_LBUTTONUP, LM_RBUTTONUP, LM_MBUTTONUP);
|
|
||||||
var
|
var
|
||||||
ActionUPP, OldActionUPP: ControlActionUPP;
|
ActionUPP, OldActionUPP: ControlActionUPP;
|
||||||
P: TPoint;
|
P: TPoint;
|
||||||
@ -266,14 +264,13 @@ begin
|
|||||||
|
|
||||||
FillChar(Msg{%H-}, SizeOf(Msg), 0);
|
FillChar(Msg{%H-}, SizeOf(Msg), 0);
|
||||||
|
|
||||||
if (MouseButton >= Low(MSGKIND)) and (MouseButton <= High(MSGKIND)) then
|
|
||||||
Msg.Msg := MSGKIND[MouseButton];
|
|
||||||
|
|
||||||
P := AWidget.GetMousePos;
|
P := AWidget.GetMousePos;
|
||||||
Msg.XPos := P.X;
|
Msg.XPos := P.X;
|
||||||
Msg.YPos := P.Y;
|
Msg.YPos := P.Y;
|
||||||
Msg.Keys := GetCarbonMsgKeyState;
|
Msg.Keys := GetCarbonMsgKeyState;
|
||||||
case GetCarbonMouseClickCount(AEvent) of
|
Msg.Msg := CheckMouseButtonDownUp(AWidget.LCLObject, LastMouse,
|
||||||
|
AWidget.LCLObject.ClientToScreen(P), MouseButton, False);
|
||||||
|
case LastMouse.ClickCount of
|
||||||
2: Msg.Keys := msg.Keys or MK_DOUBLECLICK;
|
2: Msg.Keys := msg.Keys or MK_DOUBLECLICK;
|
||||||
3: Msg.Keys := msg.Keys or MK_TRIPLECLICK;
|
3: Msg.Keys := msg.Keys or MK_TRIPLECLICK;
|
||||||
4: Msg.Keys := msg.Keys or MK_QUADCLICK;
|
4: Msg.Keys := msg.Keys or MK_QUADCLICK;
|
||||||
|
|||||||
@ -133,17 +133,8 @@ const
|
|||||||
// handler functions
|
// handler functions
|
||||||
//
|
//
|
||||||
procedure HandleMouseDownEvent(var AMsg);
|
procedure HandleMouseDownEvent(var AMsg);
|
||||||
const
|
|
||||||
// array of clickcount x buttontype
|
|
||||||
MSGKIND: array[1..4, 1..3] of Integer = (
|
|
||||||
(LM_LBUTTONDOWN, LM_RBUTTONDOWN, LM_MBUTTONDOWN),
|
|
||||||
(LM_LBUTTONDBLCLK, LM_RBUTTONDBLCLK, LM_MBUTTONDBLCLK),
|
|
||||||
(LM_LBUTTONTRIPLECLK, LM_RBUTTONTRIPLECLK, LM_MBUTTONTRIPLECLK),
|
|
||||||
(LM_LBUTTONQUADCLK, LM_RBUTTONQUADCLK, LM_MBUTTONQUADCLK)
|
|
||||||
);
|
|
||||||
var
|
var
|
||||||
MouseButton: Integer;
|
MouseButton: Integer;
|
||||||
ClickCount: Integer;
|
|
||||||
MousePoint: TPoint;
|
MousePoint: TPoint;
|
||||||
Msg: ^TLMMouse;
|
Msg: ^TLMMouse;
|
||||||
begin
|
begin
|
||||||
@ -152,30 +143,28 @@ const
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Msg := @AMsg;
|
Msg := @AMsg;
|
||||||
|
|
||||||
ClickCount := GetCarbonMouseClickCount(AEvent);
|
|
||||||
MouseButton := GetCarbonMouseButton(AEvent);
|
MouseButton := GetCarbonMouseButton(AEvent);
|
||||||
MousePoint := GetMousePoint;
|
MousePoint := GetMousePoint;
|
||||||
|
|
||||||
if (ClickCount < Low(MSGKIND)) or (ClickCount > High(MSGKIND)) then
|
Msg^.Msg := CheckMouseButtonDownUp(Widget.LCLObject, LastMouse,
|
||||||
ClickCount := (ClickCount mod High(MSGKIND))+1;
|
Widget.LCLObject.ClientToScreen(MousePoint), MouseButton, True);
|
||||||
|
|
||||||
if (MouseButton < Low(MSGKIND[1])) or (MouseButton > High(MSGKIND[1])) then Exit;
|
|
||||||
Msg^.Msg := MSGKIND[ClickCount, MouseButton];
|
|
||||||
//debugln('HandleMouseDownEvent CliCount=',dbgs(ClickCount),' MouseButton=',dbgs(MouseButton),' Pos=',dbgs(MousePoint));
|
//debugln('HandleMouseDownEvent CliCount=',dbgs(ClickCount),' MouseButton=',dbgs(MouseButton),' Pos=',dbgs(MousePoint));
|
||||||
|
|
||||||
|
|
||||||
Msg^.XPos := MousePoint.X;
|
Msg^.XPos := MousePoint.X;
|
||||||
Msg^.YPos := MousePoint.Y;
|
Msg^.YPos := MousePoint.Y;
|
||||||
Msg^.Keys := GetCarbonMsgKeyState;
|
Msg^.Keys := GetCarbonMsgKeyState;
|
||||||
|
case LastMouse.ClickCount of
|
||||||
|
2: Msg^.Keys := Msg^.Keys or MK_DOUBLECLICK;
|
||||||
|
3: Msg^.Keys := Msg^.Keys or MK_TRIPLECLICK;
|
||||||
|
4: Msg^.Keys := Msg^.Keys or MK_QUADCLICK;
|
||||||
|
end;
|
||||||
CarbonWidgetSet.SetCaptureWidget(HWND(Widget));
|
CarbonWidgetSet.SetCaptureWidget(HWND(Widget));
|
||||||
|
|
||||||
if ClickCount > 1 then Postpone := True;
|
if LastMouse.ClickCount > 1 then Postpone := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure HandleMouseUpEvent(var AMsg);
|
procedure HandleMouseUpEvent(var AMsg);
|
||||||
const
|
|
||||||
MSGKIND: array[1..3] of Integer = (LM_LBUTTONUP, LM_RBUTTONUP, LM_MBUTTONUP);
|
|
||||||
var
|
var
|
||||||
MouseButton: Integer;
|
MouseButton: Integer;
|
||||||
MousePoint: TPoint;
|
MousePoint: TPoint;
|
||||||
@ -191,13 +180,18 @@ const
|
|||||||
MouseButton := GetCarbonMouseButton(AEvent);
|
MouseButton := GetCarbonMouseButton(AEvent);
|
||||||
MousePoint := GetMousePoint;
|
MousePoint := GetMousePoint;
|
||||||
|
|
||||||
if (MouseButton >= Low(MSGKIND)) and (MouseButton <= High(MSGKIND)) then
|
Msg^.Msg := CheckMouseButtonDownUp(Widget.LCLObject, LastMouse,
|
||||||
Msg^.Msg := MSGKIND[MouseButton];
|
Widget.LCLObject.ClientToScreen(MousePoint), MouseButton, False);
|
||||||
|
|
||||||
Msg^.XPos := MousePoint.X;
|
Msg^.XPos := MousePoint.X;
|
||||||
Msg^.YPos := MousePoint.Y;
|
Msg^.YPos := MousePoint.Y;
|
||||||
Msg^.Keys := GetCarbonMsgKeyState;
|
Msg^.Keys := GetCarbonMsgKeyState;
|
||||||
|
case LastMouse.ClickCount of
|
||||||
|
2: Msg^.Keys := Msg^.Keys or MK_DOUBLECLICK;
|
||||||
|
3: Msg^.Keys := Msg^.Keys or MK_TRIPLECLICK;
|
||||||
|
4: Msg^.Keys := Msg^.Keys or MK_QUADCLICK;
|
||||||
|
end;
|
||||||
|
|
||||||
CarbonWidgetSet.SetCaptureWidget(0);
|
CarbonWidgetSet.SetCaptureWidget(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user