mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 08:58:23 +02:00
Cocoa: Treat control-left mouse click same as right mouse click to bring up context menu
This commit is contained in:
parent
06bfb3b56a
commit
6fc0212b11
@ -158,6 +158,13 @@ var
|
||||
classicFrame3d: False;
|
||||
);
|
||||
|
||||
var
|
||||
CocoaConfigMouse: TCocoaConfigMouse = (
|
||||
// False: Control-Left-Click passes straight through
|
||||
// True: Control-Left-Click will become Right Click
|
||||
controlLeftToRightClick: False;
|
||||
);
|
||||
|
||||
var
|
||||
CocoaConfigNotification: TCocoaConfigNotification = (
|
||||
// by default on macOS, Notification is only Presented when the APP is
|
||||
|
@ -302,6 +302,11 @@ type
|
||||
classicFrame3d: Boolean;
|
||||
end;
|
||||
|
||||
type
|
||||
TCocoaConfigMouse = record
|
||||
controlLeftToRightClick: Boolean;
|
||||
end;
|
||||
|
||||
type
|
||||
TCocoaConfigNotification = record
|
||||
alwaysPresent: Boolean;
|
||||
|
@ -226,6 +226,7 @@ type
|
||||
|
||||
var
|
||||
LastMouse: TLastMouseInfo;
|
||||
LastMouseLeftButtonAsRight: Boolean;
|
||||
|
||||
function ButtonStateToShiftState(BtnState: PtrUInt): TShiftState;
|
||||
begin
|
||||
@ -964,6 +965,22 @@ begin
|
||||
if AForceAsMouseUp then
|
||||
lEventType := NSLeftMouseUp;
|
||||
|
||||
if CocoaConfigMouse.controlLeftToRightClick then begin
|
||||
// treat ctrl+left button as right button
|
||||
if (lEventType = NSLeftMouseDown) and
|
||||
(Event.modifierFlags and NSControlKeyMask <> 0) then
|
||||
LastMouseLeftButtonAsRight := True;
|
||||
if LastMouseLeftButtonAsRight then
|
||||
begin
|
||||
if MButton = 0 then
|
||||
MButton := 1;
|
||||
if Msg.Keys and MK_LBUTTON <> 0 then
|
||||
Msg.Keys := (Msg.Keys or MK_RBUTTON) and not MK_LBUTTON;
|
||||
if lEventType = NSLeftMouseUp then
|
||||
LastMouseLeftButtonAsRight := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
Result := Result or (BlockCocoaUpDown and not AOverrideBlock);
|
||||
mc := CocoaWidgetSet.ModalCounter;
|
||||
case lEventType of
|
||||
|
Loading…
Reference in New Issue
Block a user