mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-10 19:03:30 +00:00
TreeNode should keep selection state when arrow clicked #1896
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#1896
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?
TreeNode should allow user to expand or collapse and keep selection state not changed, when user clicking the arrow.
Correct me if I missed something.
Thanks very much!
I am not sure what you mean by selection state, TreeNode currently don’t hold any selection state. Please provide more details.
Oh, sorry.
Here is my issue: AFAIK, we use methods like
ImGui::IsItemClicked()to trigger the selection (#1872). However, when user clicks on the arrow of the tree node,ImGui::IsItemClicked()also returns true. In this case, when a user intends to expand/collapse the node, the node will also be selected. This is not desired.I don't have a solution for it other than a workaround testing the X coordinates.
Or using
imgui_internal.h:I'll keep this open because it's an interesting issue I would like to solve along with #1861.
X coord approach appearly solves my problem. Cheers! :)
Yeah, it works for me as well! Would be nice to have a built-in for this.
You could split the TreeNodeBehaviour into two items, one button for the arrow, and one for the rest.
This should be toggeable with a
ImGuiTreeNodeFlags_SeparateArrowflag (or something similar, in which case two button behaviours and ItemAdd's are used instead of just once.Hello,
I have made two changes:
IsItemToggledOpen()call to explicitely query if the node was just closed/open making it possible to differenciate this from e..g a simple click.Both of those changes should normally answer the problem opened here now.
-Omar