Nav: Disabled items are not candidate for default focus. (#211, #787) + simplify handling of ImGuiButtonFlags_PressedOnDragDropHold path.

This commit is contained in:
ocornut
2021-07-09 16:31:40 +02:00
parent cc40ae2101
commit 4a100f7f11
3 changed files with 7 additions and 5 deletions

View File

@ -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;
}