MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / AddMouseButtonEvent

Method AddMouseButtonEvent

TheForceEngine/TFE_Ui/imGUI/imgui.cpp:1657–1703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1655}
1656
1657void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
1658{
1659 IM_ASSERT(Ctx != NULL);
1660 ImGuiContext& g = *Ctx;
1661 IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
1662 if (!AppAcceptingEvents)
1663 return;
1664
1665 // On MacOS X: Convert Ctrl(Super)+Left click into Right-click: handle held button.
1666 if (ConfigMacOSXBehaviors && mouse_button == 0 && MouseCtrlLeftAsRightClick)
1667 {
1668 // Order of both statements matterns: this event will still release mouse button 1
1669 mouse_button = 1;
1670 if (!down)
1671 MouseCtrlLeftAsRightClick = false;
1672 }
1673
1674 // Filter duplicate
1675 const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
1676 const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
1677 if (latest_button_down == down)
1678 return;
1679
1680 // On MacOS X: Convert Ctrl(Super)+Left click into Right-click.
1681 // - Note that this is actual physical Ctrl which is ImGuiMod_Super for us.
1682 // - At this point we want from !down to down, so this is handling the initial press.
1683 if (ConfigMacOSXBehaviors && mouse_button == 0 && down)
1684 {
1685 const ImGuiInputEvent* latest_super_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)ImGuiMod_Super);
1686 if (latest_super_event ? latest_super_event->Key.Down : g.IO.KeySuper)
1687 {
1688 IMGUI_DEBUG_LOG_IO("[io] Super+Left Click aliased into Right Click\n");
1689 MouseCtrlLeftAsRightClick = true;
1690 AddMouseButtonEvent(1, true); // This is just quicker to write that passing through, as we need to filter duplicate again.
1691 return;
1692 }
1693 }
1694
1695 ImGuiInputEvent e;
1696 e.Type = ImGuiInputEventType_MouseButton;
1697 e.Source = ImGuiInputSource_Mouse;
1698 e.EventId = g.InputEventsNextEventId++;
1699 e.MouseButton.Button = mouse_button;
1700 e.MouseButton.Down = down;
1701 e.MouseButton.MouseSource = g.InputEventsNextMouseSource;
1702 g.InputEventsQueue.push_back(e);
1703}
1704
1705// Queue a mouse wheel event (some mouse/API may only have a Y component)
1706void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)

Callers 1

Calls 2

FindLatestInputEventFunction · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected