mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-22 22:44:21 +00:00
Overlapped item gets click - even with SetItemAllowOverlap #6512
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#6512
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
Version: 1.89.7 WIP
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_opengl2.cpp + imgui_impl_sdl2.cpp
Compiler: gcc 13.1.1
Operating System: Linux
My Issue/Question:
I tried the example given in https://github.com/ocornut/imgui/issues/3909#issuecomment-799328231 with
SetItemAllowOverlapafter button 1, but unlike stated in the comment, when clicking into the intersection of both buttons, button 1 registers the click - not button 2. Did I miss anything?I believe my example in the linked comment is incorrect.
Low-level
ImGuiButtonFlags_AllowItemOverlapneeds to be set on the potentially overlapped item:ImGui::ButtonEx("11111", ImVec2(50, 50), ImGuiButtonFlags_AllowItemOverlap)As designed, I believe
SetItemAllowOverlap()API is a little useless.I believe this needs to be redesigned into, e.g. at minimum a
SetNextItemAllowOverlap()variant.Sorry it was too hasty to me to say that when it's not that simple.
Prior to 1.89 the code in https://github.com/ocornut/imgui/issues/3909#issuecomment-799328231 + all descriptions of behavior were fully accurate.
In 1.89 we internally started using a system for input-ownership (which wasn't really publicly advertised as a whole, but part of it was used in answers to specific problem). The way this system work broke the behavior of said snippet.
I am investigating and will post more details soon.
ImGuiButtonFlags_AllowItemOverlapworks. Thanks.From my point-of-view as a new Imgui-user, I expected that - by default - all subsequent widgets would take precedence when it comes to handling events. And in case this is not what the user wants, some kind of
ImGuiButtonFlags_Passthroughflag could be set for subsequent widgets.Anyways, thanks for your help.
Following the recent discovery that an underlying major change in 1.89 broke use of
SetItemAllowOverlap()I have worked on this topic. The resulting changes being:Changelog:
SetNextItemAllowOverlap()(called before an item) as a replacement for usingSetItemAllowOverlap()(called after an item). This is roughly equivalent to using the legacySetItemAllowOverlap()call (public API) +ImGuiButtonFlags_AllowOverlap(internal).SetItemAllowOverlap(): it didn't and couldn't work reliably since 1.89 (2022-11-15), and relied on ambiguously defined design. UseSetNextItemAllowOverlap()before item instead.ImGuiTreeNodeFlags_AllowItemOverlaptoImGuiTreeNodeFlags_AllowOverlap.ImGuiSelectableFlags_AllowItemOverlaptoImGuiSelectableFlags_AllowOverlapImGuiHoveredFlags_AllowWhenOverlappedByItem.ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_AllowOverlapand holding item held, overlapping widgets won't appear as hovered.SetNextItemAllowOverlap()(previously only a fraction of widgets did).ImGuiHoveredFlags_AllowWhenOverlappedByWindowto ignore window-overlap only. OptionImGuiHoveredFlags_AllowWhenOverlappednow expand into a combination of bothImGuiHoveredFlags_AllowWhenOverlappedByWindow+ImGuiHoveredFlags_AllowWhenOverlappedByItem, matching old behavior.Commits
06f5b46Overlap: Fixed first frame of an overlap highlighting underlying item if previous frame didn't hover anything.51f564e(Breaking) Overlap: Renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap', 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'. Kept redirecting enums (will obsolete).07e24b4ButtonBehavior: pull ImGuiButtonFlags_Repeat from ImGuiItemFlags_ButtonRepeat, matching ItemHoverable() logic. So more widgets can take advantage of Repeat logic.a9a5cbfOverlap: Internals: add NextItemData.ItemFlags to facilitate implementation of SetNextItemAllowOverlap() + potentially remove extra_flags from ItemAdd().8439a73Overlap: Added 'SetNextItemAllowOverlap()' as a replacement for 'SetItemAllowOverlap()'.10c7709IsItemHovered: Changed behavior to return false when querying an item using AllowOverlap mode. Added ImGuiHoveredFlags_AllowWhenOverlappedByItem, ImGuiHoveredFlags_AllowWhenOverlappedByWindow.4dee919(Breaking) Internals: added ImGuiItemFlags param to ItemHoverable(), so it can be called from ButtonBehavior() not following an ItemAdd().6137443Overlap: moved ImGuiItemflags_AllowOverlap handling from ButtoBehavior() to ItemHoverable() now that it is possible. This allows DragXXX, SliderXXX, PlotXXX etc to honor SetNextItemAllowOverlap().I have also updated ImPlot accordingly: https://github.com/epezent/implot/pull/486