mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
Nav, Focus: Changed SetKeyboardFocusHere() to not behave if a drag or window moving is in progress + move KeepAliveID() call from Scrollbar() to ScrollbarEx()
This commit is contained in:
parent
ddcff10343
commit
27343efb0b
@ -84,6 +84,7 @@ Other Changes:
|
|||||||
- Nav: Fixed nav movement in a scope with only one disabled item from focusing the disabled item. (#5189)
|
- Nav: Fixed nav movement in a scope with only one disabled item from focusing the disabled item. (#5189)
|
||||||
- Nav: Fixed issues with nav request being transferred to another window when calling SetKeyboardFocusHere()
|
- Nav: Fixed issues with nav request being transferred to another window when calling SetKeyboardFocusHere()
|
||||||
and simultaneous changing window focus. (#4449)
|
and simultaneous changing window focus. (#4449)
|
||||||
|
- Nav: Changed SetKeyboardFocusHere() to not behave if a drag or window moving is in progress.
|
||||||
- IsItemHovered(): added ImGuiHoveredFlags_NoNavOverride to disable the behavior where the
|
- IsItemHovered(): added ImGuiHoveredFlags_NoNavOverride to disable the behavior where the
|
||||||
return value is overriden by focus when gamepad/keyboard navigation is active.
|
return value is overriden by focus when gamepad/keyboard navigation is active.
|
||||||
- InputText: Fixed pressing Tab emitting two tabs characters because of dual Keys/Chars events being
|
- InputText: Fixed pressing Tab emitting two tabs characters because of dual Keys/Chars events being
|
||||||
|
11
imgui.cpp
11
imgui.cpp
@ -7386,6 +7386,17 @@ void ImGui::SetKeyboardFocusHere(int offset)
|
|||||||
IM_ASSERT(offset >= -1); // -1 is allowed but not below
|
IM_ASSERT(offset >= -1); // -1 is allowed but not below
|
||||||
IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere(%d) in window \"%s\"\n", offset, window->Name);
|
IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere(%d) in window \"%s\"\n", offset, window->Name);
|
||||||
|
|
||||||
|
// It makes sense in the vast majority of cases to never interrupt a drag and drop.
|
||||||
|
// When we refactor this function into ActivateItem() we may want to make this an option.
|
||||||
|
// Note that g.ActiveId being stolen while g.MovingWindow != NULL is currently ill-defined (subtle side-effects on master, assert in docking),
|
||||||
|
// so there's another layer we need to fix. Would make sense to automatically drop g.MovingWindow when g.ActiveId is changed.
|
||||||
|
// MovingWindow is protected from most user inputs using SetActiveIdUsingNavAndKeys() but we may need to enforce a better more encompassing scheme.
|
||||||
|
if (g.DragDropActive || g.MovingWindow != NULL)
|
||||||
|
{
|
||||||
|
IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere() ignored while DragDropActive!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetNavWindow(window);
|
SetNavWindow(window);
|
||||||
|
|
||||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||||
|
@ -880,9 +880,7 @@ void ImGui::Scrollbar(ImGuiAxis axis)
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
|
||||||
const ImGuiID id = GetWindowScrollbarID(window, axis);
|
const ImGuiID id = GetWindowScrollbarID(window, axis);
|
||||||
KeepAliveID(id);
|
|
||||||
|
|
||||||
// Calculate scrollbar bounding box
|
// Calculate scrollbar bounding box
|
||||||
ImRect bb = GetWindowScrollbarRect(window, axis);
|
ImRect bb = GetWindowScrollbarRect(window, axis);
|
||||||
@ -920,6 +918,8 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
|||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
KeepAliveID(id);
|
||||||
|
|
||||||
const float bb_frame_width = bb_frame.GetWidth();
|
const float bb_frame_width = bb_frame.GetWidth();
|
||||||
const float bb_frame_height = bb_frame.GetHeight();
|
const float bb_frame_height = bb_frame.GetHeight();
|
||||||
if (bb_frame_width <= 0.0f || bb_frame_height <= 0.0f)
|
if (bb_frame_width <= 0.0f || bb_frame_height <= 0.0f)
|
||||||
|
Loading…
Reference in New Issue
Block a user