MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / AddMouseButtonEvent

Method AddMouseButtonEvent

external/imgui/imgui.cpp:1939–1985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1937}
1938
1939void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
1940{
1941 IM_ASSERT(Ctx != NULL);
1942 ImGuiContext& g = *Ctx;
1943 IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
1944 if (!AppAcceptingEvents)
1945 return;
1946
1947 // On MacOS X: Convert Ctrl(Super)+Left click into Right-click: handle held button.
1948 if (ConfigMacOSXBehaviors && mouse_button == 0 && MouseCtrlLeftAsRightClick)
1949 {
1950 // Order of both statements matters: this event will still release mouse button 1
1951 mouse_button = 1;
1952 if (!down)
1953 MouseCtrlLeftAsRightClick = false;
1954 }
1955
1956 // Filter duplicate
1957 const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
1958 const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
1959 if (latest_button_down == down)
1960 return;
1961
1962 // On MacOS X: Convert Ctrl(Super)+Left click into Right-click.
1963 // - Note that this is actual physical Ctrl which is ImGuiMod_Super for us.
1964 // - At this point we want from !down to down, so this is handling the initial press.
1965 if (ConfigMacOSXBehaviors && mouse_button == 0 && down)
1966 {
1967 const ImGuiInputEvent* latest_super_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)ImGuiMod_Super);
1968 if (latest_super_event ? latest_super_event->Key.Down : g.IO.KeySuper)
1969 {
1970 IMGUI_DEBUG_LOG_IO("[io] Super+Left Click aliased into Right Click\n");
1971 MouseCtrlLeftAsRightClick = true;
1972 AddMouseButtonEvent(1, true); // This is just quicker to write that passing through, as we need to filter duplicate again.
1973 return;
1974 }
1975 }
1976
1977 ImGuiInputEvent e;
1978 e.Type = ImGuiInputEventType_MouseButton;
1979 e.Source = ImGuiInputSource_Mouse;
1980 e.EventId = g.InputEventsNextEventId++;
1981 e.MouseButton.Button = mouse_button;
1982 e.MouseButton.Down = down;
1983 e.MouseButton.MouseSource = g.InputEventsNextMouseSource;
1984 g.InputEventsQueue.push_back(e);
1985}
1986
1987// Queue a mouse wheel event (some mouse/API may only have a Y component)
1988void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)

Calls 2

FindLatestInputEventFunction · 0.85
push_backMethod · 0.45

Tested by

no test coverage detected