mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Selectable: With ImGuiSelectableFlags_AllowDoubleClick doesn't return true on the mouse button releas efollowing the double-click. Only first mouse release + second mouse down (double-click) returns true. Likewise for internal ButtonBehavior() with both _PressedOnClickRelease | _PressedOnDoubleClick. (#2503)
This commit is contained in:
parent
86f92fe756
commit
2dc81057ec
@ -74,6 +74,9 @@ Other Changes:
|
||||
clear the focus again.
|
||||
- Popups: Fixed right-click from closing all popups instead of aiming at the hovered popup level
|
||||
(regression in 1.67).
|
||||
- Selectable: With ImGuiSelectableFlags_AllowDoubleClick doesn't return true on the mouse button release
|
||||
following the double-click. Only first mouse release + second mouse down (double-click) returns true.
|
||||
Likewise for internal ButtonBehavior() with both _PressedOnClickRelease | _PressedOnDoubleClick. (#2503)
|
||||
- GetMouseDragDelta(): also returns the delta on the mouse button released frame. (#2419)
|
||||
- GetMouseDragDelta(): verify that mouse positions are valid otherwise returns zero.
|
||||
- Inputs: Also add support for horizontal scroll with Shift+Mouse Wheel. (#2424, #1463) [@LucaRood]
|
||||
|
@ -3282,6 +3282,7 @@ static void ImGui::UpdateMouseInputs()
|
||||
g.IO.MouseClickedTime[i] = g.Time;
|
||||
}
|
||||
g.IO.MouseClickedPos[i] = g.IO.MousePos;
|
||||
g.IO.MouseDownWasDoubleClick[i] = g.IO.MouseDoubleClicked[i];
|
||||
g.IO.MouseDragMaxDistanceAbs[i] = ImVec2(0.0f, 0.0f);
|
||||
g.IO.MouseDragMaxDistanceSqr[i] = 0.0f;
|
||||
}
|
||||
@ -3293,6 +3294,8 @@ static void ImGui::UpdateMouseInputs()
|
||||
g.IO.MouseDragMaxDistanceAbs[i].x = ImMax(g.IO.MouseDragMaxDistanceAbs[i].x, delta_from_click_pos.x < 0.0f ? -delta_from_click_pos.x : delta_from_click_pos.x);
|
||||
g.IO.MouseDragMaxDistanceAbs[i].y = ImMax(g.IO.MouseDragMaxDistanceAbs[i].y, delta_from_click_pos.y < 0.0f ? -delta_from_click_pos.y : delta_from_click_pos.y);
|
||||
}
|
||||
if (!g.IO.MouseDown[i] && !g.IO.MouseReleased[i])
|
||||
g.IO.MouseDownWasDoubleClick[i] = false;
|
||||
if (g.IO.MouseClicked[i]) // Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation
|
||||
g.NavDisableMouseHover = false;
|
||||
}
|
||||
|
3
imgui.h
3
imgui.h
@ -1435,7 +1435,8 @@ struct ImGuiIO
|
||||
bool MouseClicked[5]; // Mouse button went from !Down to Down
|
||||
bool MouseDoubleClicked[5]; // Has mouse button been double-clicked?
|
||||
bool MouseReleased[5]; // Mouse button went from Down to !Down
|
||||
bool MouseDownOwned[5]; // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds.
|
||||
bool MouseDownOwned[5]; // Track if button was clicked inside an imgui window. We don't request mouse capture from the application if click started outside ImGui bounds.
|
||||
bool MouseDownWasDoubleClick[5]; // Track if button down was a double-click
|
||||
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
||||
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
||||
ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point
|
||||
|
@ -429,6 +429,10 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
|
||||
// Frame N+6 (mouse button is released) - true - - true -
|
||||
// Frame N+7 (mouse button is released) - true - - - -
|
||||
//------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Note that some combinations are supported,
|
||||
// - PressedOnDragDropHold can generally be associated with any flag.
|
||||
// - PressedOnDoubleClick can be associated by PressedOnClickRelease/PressedOnRelease, in which case the second release event won't be reported.
|
||||
//------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// The behavior of the return-value changes when ImGuiButtonFlags_Repeat is set:
|
||||
// Repeat+ Repeat+ Repeat+ Repeat+
|
||||
// PressedOnClickRelease PressedOnClick PressedOnRelease PressedOnDoubleClick
|
||||
@ -569,10 +573,13 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease))
|
||||
if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps <on release>
|
||||
if (!g.DragDropActive)
|
||||
if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) && !g.DragDropActive)
|
||||
{
|
||||
bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[0];
|
||||
bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay; // Repeat mode trumps <on release>
|
||||
if (!is_double_click_release && !is_repeating_already)
|
||||
pressed = true;
|
||||
}
|
||||
ClearActiveID();
|
||||
}
|
||||
if (!(flags & ImGuiButtonFlags_NoNavFocus))
|
||||
|
Loading…
Reference in New Issue
Block a user