mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-10 19:03:30 +00:00
Add option to TreeNode to enable button behaviour with key modifiers enabled. #2886
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 milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#2886
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?
Hi, I am working on a multiselection tree hierarchy and using LCTRL as the modifier to select multiple items. My idea is to be able to while holding down the LCTRL key, open a tree node if I click on the arrow. Right now, the default behaviour of the button behaviour inside the TreeNode is to include the ImGuiButtonFlags_NoKeyModifiers flag which prevents me from doing so.
I have manually removed the default flag, but I guess having a proper way of disabling this behaviour would be the ideal solution.
Thanks.
Which tree node flags are you using? Are you using
ImGuiTreeNodeFlags_OpenOnArrow, or are not your using it and expecting a different behavior based on whether CTRL and click are happening over the arrow or before/after ?My gut feeling is that for tree node it would make sense to allow toggling the node open state with modifiers when clicking specifically on the arrow, so we could alter the behavior based on mouse position. I'll have to check with
features/range_selectand think about other side-effects or doing this.Potential fix would be to move the arrow_x1/arrow_x2 declaration higher in the function and alter the button flags based on
io.MousePos.x.(Also need to consider
ImGuiTreeNodeFlags_SpanFullWidthbeing used which mean we can click before the arrow.)Also consider looking at #1861 and the
features/range_selectbranch.(PS: Please fill the issue template as requested when creating a new issue.)
I applied the change described above now.
In addition, I have added
IsItemToggledOpen()to explicitely query if the node was just open/closed which is required to fully handle #1896.Thank you for the quick fix, it is exactly what I needed.
I was using ImGuiTreeNodeFlags_SpanFullWidth and doing a range check to see if the mouse was in the arrow area when clicked using the TreeDepth, but with IsItemToggledOpen() should be way easier and cleaner.
And sorry for the template, I must have cleared the text and forgot about it completely.