83ecc84
was too not supporting widgets using ItemHoverable() directly + too complex. Revert83ecc84
in ButtonBehavior(), reimplement in UpdateMouseMovingWindowEndFrame()>
This commit is contained in:
parent
04d9a04557
commit
706438a43c
10
imgui.cpp
10
imgui.cpp
@ -4875,12 +4875,13 @@ void ImGui::UpdateMouseMovingWindowNewFrame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiate moving window when clicking on empty space or title bar.
|
// Initiate focusing and moving window when clicking on empty space or title bar.
|
||||||
|
// Initiate focusing window when clicking on a disabled item.
|
||||||
// Handle left-click and right-click focus.
|
// Handle left-click and right-click focus.
|
||||||
void ImGui::UpdateMouseMovingWindowEndFrame()
|
void ImGui::UpdateMouseMovingWindowEndFrame()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.ActiveId != 0 || g.HoveredId != 0)
|
if (g.ActiveId != 0 || (g.HoveredId != 0 && !g.HoveredIdIsDisabled))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Unless we just made a window/popup appear
|
// Unless we just made a window/popup appear
|
||||||
@ -4906,7 +4907,8 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
|
|||||||
if (!root_window->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
|
if (!root_window->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
|
||||||
g.MovingWindow = NULL;
|
g.MovingWindow = NULL;
|
||||||
|
|
||||||
// Cancel moving if clicked over an item which was disabled or inhibited by popups (note that we know HoveredId == 0 already)
|
// Cancel moving if clicked over an item which was disabled or inhibited by popups
|
||||||
|
// (when g.HoveredIdIsDisabled == true && g.HoveredId == 0 we are inhibited by popups, when g.HoveredIdIsDisabled == true && g.HoveredId != 0 we are over a disabled item)0 already)
|
||||||
if (g.HoveredIdIsDisabled)
|
if (g.HoveredIdIsDisabled)
|
||||||
g.MovingWindow = NULL;
|
g.MovingWindow = NULL;
|
||||||
}
|
}
|
||||||
@ -4920,7 +4922,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
|
|||||||
// With right mouse button we close popups without changing focus based on where the mouse is aimed
|
// With right mouse button we close popups without changing focus based on where the mouse is aimed
|
||||||
// Instead, focus will be restored to the window under the bottom-most closed popup.
|
// Instead, focus will be restored to the window under the bottom-most closed popup.
|
||||||
// (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger)
|
// (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger)
|
||||||
if (g.IO.MouseClicked[1])
|
if (g.IO.MouseClicked[1] && g.HoveredId == 0)
|
||||||
{
|
{
|
||||||
// Find the top-most window between HoveredWindow and the top-most Modal Window.
|
// Find the top-most window between HoveredWindow and the top-most Modal Window.
|
||||||
// This is where we can trim the popup stack.
|
// This is where we can trim the popup stack.
|
||||||
|
@ -542,8 +542,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
|
|
||||||
// Mouse handling
|
// Mouse handling
|
||||||
const ImGuiID test_owner_id = (flags & ImGuiButtonFlags_NoTestKeyOwner) ? ImGuiKeyOwner_Any : id;
|
const ImGuiID test_owner_id = (flags & ImGuiButtonFlags_NoTestKeyOwner) ? ImGuiKeyOwner_Any : id;
|
||||||
const bool hovered_disabled = (g.HoveredId == id && g.HoveredIdIsDisabled);
|
if (hovered)
|
||||||
if (hovered || hovered_disabled)
|
|
||||||
{
|
{
|
||||||
IM_ASSERT(id != 0); // Lazily check inside rare path.
|
IM_ASSERT(id != 0); // Lazily check inside rare path.
|
||||||
|
|
||||||
@ -561,7 +560,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
|
|
||||||
// Process initial action
|
// Process initial action
|
||||||
const bool mods_ok = !(flags & ImGuiButtonFlags_NoKeyModsAllowed) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt);
|
const bool mods_ok = !(flags & ImGuiButtonFlags_NoKeyModsAllowed) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt);
|
||||||
if (mods_ok && !hovered_disabled)
|
if (mods_ok)
|
||||||
{
|
{
|
||||||
if (mouse_button_clicked != -1 && g.ActiveId != id)
|
if (mouse_button_clicked != -1 && g.ActiveId != id)
|
||||||
{
|
{
|
||||||
@ -619,17 +618,6 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, ImGuiInputFlags_Repeat, test_owner_id))
|
if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, ImGuiInputFlags_Repeat, test_owner_id))
|
||||||
pressed = true;
|
pressed = true;
|
||||||
}
|
}
|
||||||
else if (mods_ok && hovered_disabled)
|
|
||||||
{
|
|
||||||
if (mouse_button_clicked != -1 && g.ActiveId != id)
|
|
||||||
{
|
|
||||||
// Disabled path still focus
|
|
||||||
// FIXME-NAV: Could somehow call SetNavID() with a null ID but mouse pos as NavRectRel so nav may be resumed?
|
|
||||||
// Will do it once we do it for regular click on window-void.
|
|
||||||
if (flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick))
|
|
||||||
FocusWindow(window, ImGuiFocusRequestFlags_RestoreFocusedChild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pressed)
|
if (pressed)
|
||||||
g.NavDisableHighlight = true;
|
g.NavDisableHighlight = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user