MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / AddMouseButtonEvent

Method AddMouseButtonEvent

Dependencies/ImGui/src/imgui.cpp:1778–1824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1776}
1777
1778void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
1779{
1780 IM_ASSERT(Ctx != NULL);
1781 ImGuiContext& g = *Ctx;
1782 IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
1783 if (!AppAcceptingEvents)
1784 return;
1785
1786 // On MacOS X: Convert Ctrl(Super)+Left click into Right-click: handle held button.
1787 if (ConfigMacOSXBehaviors && mouse_button == 0 && MouseCtrlLeftAsRightClick)
1788 {
1789 // Order of both statements matterns: this event will still release mouse button 1
1790 mouse_button = 1;
1791 if (!down)
1792 MouseCtrlLeftAsRightClick = false;
1793 }
1794
1795 // Filter duplicate
1796 const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
1797 const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
1798 if (latest_button_down == down)
1799 return;
1800
1801 // On MacOS X: Convert Ctrl(Super)+Left click into Right-click.
1802 // - Note that this is actual physical Ctrl which is ImGuiMod_Super for us.
1803 // - At this point we want from !down to down, so this is handling the initial press.
1804 if (ConfigMacOSXBehaviors && mouse_button == 0 && down)
1805 {
1806 const ImGuiInputEvent* latest_super_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)ImGuiMod_Super);
1807 if (latest_super_event ? latest_super_event->Key.Down : g.IO.KeySuper)
1808 {
1809 IMGUI_DEBUG_LOG_IO("[io] Super+Left Click aliased into Right Click\n");
1810 MouseCtrlLeftAsRightClick = true;
1811 AddMouseButtonEvent(1, true); // This is just quicker to write that passing through, as we need to filter duplicate again.
1812 return;
1813 }
1814 }
1815
1816 ImGuiInputEvent e;
1817 e.Type = ImGuiInputEventType_MouseButton;
1818 e.Source = ImGuiInputSource_Mouse;
1819 e.EventId = g.InputEventsNextEventId++;
1820 e.MouseButton.Button = mouse_button;
1821 e.MouseButton.Down = down;
1822 e.MouseButton.MouseSource = g.InputEventsNextMouseSource;
1823 g.InputEventsQueue.push_back(e);
1824}
1825
1826// Queue a mouse wheel event (some mouse/API may only have a Y component)
1827void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)

Callers 1

Calls 2

FindLatestInputEventFunction · 0.85
push_backMethod · 0.45

Tested by

no test coverage detected