Skip to content

Commit

Permalink
InvisibleButton: disable navigation properly + added ImGuiButtonFlags…
Browse files Browse the repository at this point in the history
…_EnableNav to enable navigation. (#8057)
  • Loading branch information
ocornut committed Oct 16, 2024
1 parent 971d243 commit 67e5f35
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ Other changes:
- Nav: fixed Ctrl+Tab so when starting with no focused window it starts from the top-most
window. (#3200)
- Nav: rectangle highlight not rendered for items with ImGuiItemFlags_NoNav. Can be relevant
when e.g activating the item with mouse, then ctrl+tabbing back and forth.
when e.g activating the item with mouse, then Ctrl+Tabbing back and forth.
- InvisibleButton, Nav: fixed an issue when InvisibleButton() would be navigable into but
not display navigation highlight. Properly navigation on it by default. (#8057)
- InvisibleButton: added ImGuiButtonFlags_EnableNav to enable navigation. (#8057)
- Tooltips: fixed incorrect tooltip positioning when using keyboard/gamepad navigation
(1.91.3 regression). (#8036)
- DrawList: AddCallback() added an optional size parameter allowing to copy and
Expand Down
2 changes: 1 addition & 1 deletion imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ enum ImGuiButtonFlags_
ImGuiButtonFlags_MouseButtonRight = 1 << 1, // React on right mouse button
ImGuiButtonFlags_MouseButtonMiddle = 1 << 2, // React on center mouse button
ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle, // [Internal]
//ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft,
ImGuiButtonFlags_EnableNav = 1 << 3, // InvisibleButton(): do not disable navigation/tabbing. Otherwise disabled by default.
};

// Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton()
Expand Down
2 changes: 1 addition & 1 deletion imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ enum ImGuiSelectableFlagsPrivate_
enum ImGuiTreeNodeFlagsPrivate_
{
ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 28,// FIXME-WIP: Hard-coded for CollapsingHeader()
ImGuiTreeNodeFlags_UpsideDownArrow = 1 << 29,// FIXME-WIP: Turn Down arrow into an Up arrow, but reversed trees (#6517)
ImGuiTreeNodeFlags_UpsideDownArrow = 1 << 29,// FIXME-WIP: Turn Down arrow into an Up arrow, for reversed trees (#6517)
ImGuiTreeNodeFlags_OpenOnMask_ = ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_OpenOnArrow,
};

Expand Down
3 changes: 2 additions & 1 deletion imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,12 @@ bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg, ImGuiBut
ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
ItemSize(size);
if (!ItemAdd(bb, id))
if (!ItemAdd(bb, id, NULL, (flags & ImGuiButtonFlags_EnableNav) ? ImGuiItemFlags_None : ImGuiItemFlags_NoNav))
return false;

bool hovered, held;
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
RenderNavHighlight(bb, id);

IMGUI_TEST_ENGINE_ITEM_INFO(id, str_id, g.LastItemData.StatusFlags);
return pressed;
Expand Down

0 comments on commit 67e5f35

Please sign in to comment.