| 1821 | } |
| 1822 | |
| 1823 | void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down) |
| 1824 | { |
| 1825 | IM_ASSERT(Ctx != NULL); |
| 1826 | ImGuiContext& g = *Ctx; |
| 1827 | IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT); |
| 1828 | if (!AppAcceptingEvents) |
| 1829 | return; |
| 1830 | |
| 1831 | // On MacOS X: Convert Ctrl(Super)+Left click into Right-click: handle held button. |
| 1832 | if (ConfigMacOSXBehaviors && mouse_button == 0 && MouseCtrlLeftAsRightClick) |
| 1833 | { |
| 1834 | // Order of both statements matters: this event will still release mouse button 1 |
| 1835 | mouse_button = 1; |
| 1836 | if (!down) |
| 1837 | MouseCtrlLeftAsRightClick = false; |
| 1838 | } |
| 1839 | |
| 1840 | // Filter duplicate |
| 1841 | const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button); |
| 1842 | const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button]; |
| 1843 | if (latest_button_down == down) |
| 1844 | return; |
| 1845 | |
| 1846 | // On MacOS X: Convert Ctrl(Super)+Left click into Right-click. |
| 1847 | // - Note that this is actual physical Ctrl which is ImGuiMod_Super for us. |
| 1848 | // - At this point we want from !down to down, so this is handling the initial press. |
| 1849 | if (ConfigMacOSXBehaviors && mouse_button == 0 && down) |
| 1850 | { |
| 1851 | const ImGuiInputEvent* latest_super_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)ImGuiMod_Super); |
| 1852 | if (latest_super_event ? latest_super_event->Key.Down : g.IO.KeySuper) |
| 1853 | { |
| 1854 | IMGUI_DEBUG_LOG_IO("[io] Super+Left Click aliased into Right Click\n"); |
| 1855 | MouseCtrlLeftAsRightClick = true; |
| 1856 | AddMouseButtonEvent(1, true); // This is just quicker to write that passing through, as we need to filter duplicate again. |
| 1857 | return; |
| 1858 | } |
| 1859 | } |
| 1860 | |
| 1861 | ImGuiInputEvent e; |
| 1862 | e.Type = ImGuiInputEventType_MouseButton; |
| 1863 | e.Source = ImGuiInputSource_Mouse; |
| 1864 | e.EventId = g.InputEventsNextEventId++; |
| 1865 | e.MouseButton.Button = mouse_button; |
| 1866 | e.MouseButton.Down = down; |
| 1867 | e.MouseButton.MouseSource = g.InputEventsNextMouseSource; |
| 1868 | g.InputEventsQueue.push_back(e); |
| 1869 | } |
| 1870 | |
| 1871 | // Queue a mouse wheel event (some mouse/API may only have a Y component) |
| 1872 | void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y) |
no test coverage detected