|
@@ -1608,12 +1608,36 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
|
|
if (!AppAcceptingEvents)
|
|
|
return;
|
|
|
|
|
|
+ // On MacOS X: Convert Ctrl(Super)+Left click into Right-click: handle held button.
|
|
|
+ if (ConfigMacOSXBehaviors && mouse_button == 0 && MouseCtrlLeftAsRightClick)
|
|
|
+ {
|
|
|
+ // Order of both statements matterns: this event will still release mouse button 1
|
|
|
+ mouse_button = 1;
|
|
|
+ if (!down)
|
|
|
+ MouseCtrlLeftAsRightClick = false;
|
|
|
+ }
|
|
|
+
|
|
|
// Filter duplicate
|
|
|
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
|
|
|
const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
|
|
|
if (latest_button_down == down)
|
|
|
return;
|
|
|
|
|
|
+ // On MacOS X: Convert Ctrl(Super)+Left click into Right-click.
|
|
|
+ // - Note that this is actual physical Ctrl which is ImGuiMod_Super for us.
|
|
|
+ // - At this point we want from !down to down, so this is handling the initial press.
|
|
|
+ if (ConfigMacOSXBehaviors && mouse_button == 0 && down)
|
|
|
+ {
|
|
|
+ const ImGuiInputEvent* latest_super_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)ImGuiMod_Super);
|
|
|
+ if (latest_super_event ? latest_super_event->Key.Down : g.IO.KeySuper)
|
|
|
+ {
|
|
|
+ IMGUI_DEBUG_LOG_IO("[io] Super+Left Click aliased into Right Click\n");
|
|
|
+ MouseCtrlLeftAsRightClick = true;
|
|
|
+ AddMouseButtonEvent(1, true); // This is just quicker to write that passing through, as we need to filter duplicate again.
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
ImGuiInputEvent e;
|
|
|
e.Type = ImGuiInputEventType_MouseButton;
|
|
|
e.Source = ImGuiInputSource_Mouse;
|