mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-30 18:34:34 +01:00
Nav: Disabled items are not candidate for default focus. (#211, #787) + simplify handling of ImGuiButtonFlags_PressedOnDragDropHold path.
This commit is contained in:
parent
cc40ae2101
commit
4a100f7f11
@ -54,6 +54,7 @@ Other Changes:
|
||||
- TabBar: Fixed using more than 32 KB-worth of tab names. (#4176)
|
||||
- Drag and Drop: drop target highlight doesn't try to bypass host clipping rectangle. (#4281, #3272)
|
||||
- Menus: MenuItem() and BeginMenu() are not affected/overlapping when style.SelectableTextAlign is altered.
|
||||
- Nav: Disabled items are not candidate for default focus. (#211, #787)
|
||||
- Fixed printf-style format checks on non-MinGW flavors. (#4183, #3592)
|
||||
- Fonts: Functions with a 'float size_pixels' parameter can accept zero if it is set in ImFontSize::SizePixels.
|
||||
- Fonts: Prefer using U+FFFD character for fallback instead of '?', if available. (#4269)
|
||||
|
@ -8846,12 +8846,13 @@ static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, con
|
||||
if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent)
|
||||
{
|
||||
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
|
||||
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus) || g.NavInitResultId == 0)
|
||||
const bool candidate_for_nav_default_focus = (item_flags & (ImGuiItemFlags_NoNavDefaultFocus | ImGuiItemFlags_Disabled)) == 0;
|
||||
if (candidate_for_nav_default_focus || g.NavInitResultId == 0)
|
||||
{
|
||||
g.NavInitResultId = id;
|
||||
g.NavInitResultRectRel = nav_bb_rel;
|
||||
}
|
||||
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
||||
if (candidate_for_nav_default_focus)
|
||||
{
|
||||
g.NavInitRequest = false; // Found a match, clear request
|
||||
NavUpdateAnyRequestFlag();
|
||||
@ -11246,7 +11247,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]);
|
||||
Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
|
||||
Text("ActiveIdUsing: Wheel: %d, NavDirMask: %X, NavInputMask: %X, KeyInputMask: %llX", g.ActiveIdUsingMouseWheel, g.ActiveIdUsingNavDirMask, g.ActiveIdUsingNavInputMask, g.ActiveIdUsingKeyInputMask);
|
||||
Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
|
||||
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Not displaying g.HoveredId as it is update mid-frame
|
||||
Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
|
||||
Unindent();
|
||||
|
||||
|
@ -527,7 +527,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
{
|
||||
hovered = true;
|
||||
SetHoveredID(id);
|
||||
if (CalcTypematicRepeatAmount(g.HoveredIdTimer + 0.0001f - g.IO.DeltaTime, g.HoveredIdTimer + 0.0001f, DRAGDROP_HOLD_TO_OPEN_TIMER, 0.00f))
|
||||
if (g.HoveredIdTimer - g.IO.DeltaTime <= DRAGDROP_HOLD_TO_OPEN_TIMER && g.HoveredIdTimer >= DRAGDROP_HOLD_TO_OPEN_TIMER)
|
||||
{
|
||||
pressed = true;
|
||||
g.DragDropHoldJustPressedId = id;
|
||||
@ -6140,7 +6140,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
if (flags & ImGuiSelectableFlags_Disabled)
|
||||
{
|
||||
ImGuiItemFlags backup_item_flags = g.CurrentItemFlags;
|
||||
g.CurrentItemFlags |= ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus;
|
||||
g.CurrentItemFlags |= ImGuiItemFlags_Disabled;
|
||||
item_add = ItemAdd(bb, id);
|
||||
g.CurrentItemFlags = backup_item_flags;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user