mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-01 03:49:22 +02:00
LCL carbon: fixed mouse button handling with help from Alexander Grau
git-svn-id: trunk@14324 -
This commit is contained in:
parent
6202babb26
commit
975886c991
@ -2,6 +2,7 @@ The following people contributed to Lazarus:
|
||||
|
||||
A. J. Venter
|
||||
Aleksey Lagunov
|
||||
Alexander Grau
|
||||
Alexander Shiyan
|
||||
Alexandre Leclerc
|
||||
Alexandru Alexandrov
|
||||
|
@ -150,7 +150,7 @@ var
|
||||
ActionUPP, OldActionUPP: ControlActionUPP;
|
||||
P: TPoint;
|
||||
Msg: TLMMouse;
|
||||
MouseButton: EventMouseButton;
|
||||
MouseButton: Integer;
|
||||
ControlPart: ControlPartCode;
|
||||
const
|
||||
SName = 'CarbonCommon_Track';
|
||||
@ -163,11 +163,8 @@ begin
|
||||
GetEventParameter(AEvent, kEventParamControlAction, typeControlActionUPP,
|
||||
nil, SizeOf(ActionUPP), nil, @OldActionUPP), SName, SGetEvent,
|
||||
SControlAction) then Exit;
|
||||
|
||||
if OSError(
|
||||
GetEventParameter(AEvent, kEventParamMouseButton, typeMouseButton, nil,
|
||||
SizeOf(EventMouseButton), nil, @MouseButton), SName, SGetEvent,
|
||||
'kEventParamMouseButton') then Exit;
|
||||
|
||||
MouseButton := GetCarbonMouseButton(AEvent);
|
||||
|
||||
ActionUPP := NewControlActionUPP(@CarbonCommon_TrackProgress);
|
||||
try
|
||||
|
@ -83,21 +83,6 @@ const
|
||||
//debugln('GetClickCount ClickCount=',dbgs(ClickCount));
|
||||
end;
|
||||
|
||||
function GetMouseButton: Integer;
|
||||
// 1 = left, 2 = right, 3 = middle
|
||||
var
|
||||
MouseButton: EventMouseButton;
|
||||
begin
|
||||
Result := 0;
|
||||
|
||||
if OSError(
|
||||
GetEventParameter(AEvent, kEventParamMouseButton, typeMouseButton, nil,
|
||||
SizeOf(MouseButton), nil, @MouseButton),
|
||||
SName, SGetEvent, 'kEventParamMouseButton', eventParameterNotFoundErr) then Exit;
|
||||
|
||||
Result := MouseButton;
|
||||
end;
|
||||
|
||||
function GetMousePoint: TPoint;
|
||||
var
|
||||
MousePoint: HIPoint;
|
||||
@ -153,7 +138,7 @@ const
|
||||
Msg := @AMsg;
|
||||
|
||||
ClickCount := GetClickCount;
|
||||
MouseButton := GetMouseButton;
|
||||
MouseButton := GetCarbonMouseButton(AEvent);
|
||||
MousePoint := GetMousePoint;
|
||||
|
||||
if (ClickCount < Low(MSGKIND)) or (ClickCount > High(MSGKIND)) then
|
||||
@ -185,7 +170,7 @@ const
|
||||
// perhaps mousetracking can fix this
|
||||
Msg := @AMsg;
|
||||
|
||||
MouseButton := GetMouseButton;
|
||||
MouseButton := GetCarbonMouseButton(AEvent);
|
||||
MousePoint := GetMousePoint;
|
||||
|
||||
if (MouseButton >= Low(MSGKIND)) and (MouseButton <= High(MSGKIND)) then
|
||||
@ -237,7 +222,7 @@ const
|
||||
MousePoint := GetMousePoint;
|
||||
|
||||
Msg^.Msg := LM_MOUSEWHEEL;
|
||||
Msg^.Button := GetMouseButton;
|
||||
Msg^.Button := GetCarbonMouseButton(AEvent);
|
||||
Msg^.X := MousePoint.X;
|
||||
Msg^.Y := MousePoint.Y;
|
||||
Msg^.State := GetCarbonShiftState;
|
||||
@ -311,7 +296,7 @@ begin
|
||||
end;
|
||||
|
||||
// interactive design
|
||||
if (Widget is TCarbonDesignWindow) and (GetMouseButton = 1) and
|
||||
if (Widget is TCarbonDesignWindow) and (GetCarbonMouseButton(AEvent) = 1) and
|
||||
(EventKind = kEventMouseDown) then
|
||||
begin
|
||||
P := GetMousePoint;
|
||||
|
@ -63,6 +63,7 @@ function VirtualKeyCodeToMac(AKey: Word): Word;
|
||||
|
||||
function FormBorderToWindowAttrs(const AFormBorder: TFormBorderStyle): WindowAttributes;
|
||||
|
||||
function GetCarbonMouseButton(AEvent: EventRef): Integer;
|
||||
function GetCarbonMsgKeyState: PtrInt;
|
||||
function GetCarbonShiftState: TShiftState;
|
||||
function ShiftStateToModifiers(const Shift: TShiftState): Byte;
|
||||
@ -333,6 +334,42 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Name: GetCarbonMouseButton
|
||||
Returns: The event state of mouse
|
||||
------------------------------------------------------------------------------}
|
||||
function GetCarbonMouseButton(AEvent: EventRef): Integer;
|
||||
// 1 = left, 2 = right, 3 = middle
|
||||
var
|
||||
MouseButton: EventMouseButton;
|
||||
Modifiers: UInt32;
|
||||
const
|
||||
SName = 'GetCarbonMouseButton';
|
||||
begin
|
||||
Result := 0;
|
||||
Modifiers := 0;
|
||||
|
||||
if OSError(
|
||||
GetEventParameter(AEvent, kEventParamMouseButton, typeMouseButton, nil,
|
||||
SizeOf(MouseButton), nil, @MouseButton),
|
||||
SName, SGetEvent, 'kEventParamMouseButton', eventParameterNotFoundErr) then Exit;
|
||||
Result := MouseButton;
|
||||
|
||||
if OSError(
|
||||
GetEventParameter(AEvent, kEventParamKeyModifiers, typeUInt32, nil,
|
||||
SizeOf(Modifiers), nil, @Modifiers),
|
||||
SName, SGetEvent, 'kEventParamKeyModifiers', eventParameterNotFoundErr) then Exit;
|
||||
|
||||
if Result = 1 then
|
||||
begin
|
||||
if (Modifiers and optionKey) > 0 then
|
||||
Result := 3
|
||||
else
|
||||
if (Modifiers and controlKey) > 0 then
|
||||
Result := 2;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Name: GetCarbonMsgKeyState
|
||||
Returns: The current state of mouse and function keys
|
||||
|
Loading…
Reference in New Issue
Block a user