Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree node should have select()/deselect() functions #20548

Closed
LikeLakers2 opened this issue Jul 28, 2018 · 8 comments · Fixed by #71056
Closed

Tree node should have select()/deselect() functions #20548

LikeLakers2 opened this issue Jul 28, 2018 · 8 comments · Fixed by #71056

Comments

@LikeLakers2
Copy link
Contributor

LikeLakers2 commented Jul 28, 2018

I feel like this one is self-explanatory. My reasoning for this is that using TreeItem.selected doesn't update the Tree's get_selected() result, which turned into me having to make my own selected_item variable just so I could make it null whenever I don't have an item selected.

On that note, it would also be useful to allow deselecting all TreeItems whenever whitespace is clicked. It's not that hard to deselect all in GDscript, but I feel it'd be welcome as an option.

@AlexHolly
Copy link
Contributor

get_select() is not updated in Tree.SELECT_MULTI mode.

https://github.com/godotengine/godot/blob/master/scene/gui/tree.cpp#L3077
selected_item = p_item;

@LikeLakers2
Copy link
Contributor Author

@AlexHolly Did you mean to make a new issue? This is a feature proposal, not a bug report; I don't think bugs should be reported on a feature proposal.

@AlexHolly
Copy link
Contributor

I feel like this one is self-explanatory. My reasoning for this is that using TreeItem.selected doesn't update the Tree's get_selected() result, which turned into me having to make my own..

Do you think it should be updated? I would make a PR and fix both.

@LikeLakers2
Copy link
Contributor Author

LikeLakers2 commented Aug 22, 2018

@AlexHolly If you'd like to try, go for it. I'd be up for it.

Also, I see your reasoning now for the bug report being here, instead of in its own issue -- my bad!

@Eoin-ONeill-Yokai
Copy link
Contributor

Is there something I'm missing here?

I have a situation where my Tree might need to be reconstructed. In that situation, I would like to be able to modify the selected item, but that seems to be impossible to do via GDScript. So is there no way at all to change the visually selected item through GDScript alone?

@radlotus
Copy link

radlotus commented Jun 25, 2022

Yeah. It seems to be impossible to select a TreeItem via GDScript. Is it because the Editor doesn't use such feature? It would be very convenient actually.

@marzecdawid
Copy link
Contributor

@radlotus It look like methods TreeItem:Select() and TreeItem:Deselect() are exposed in GDScript for many years:
https://docs.godotengine.org/en/stable/classes/class_treeitem.html#class-treeitem-method-select

Can you clarify if this is the functionality you were looking for?

@egiezen
Copy link

egiezen commented Jan 14, 2023

The method Tree.deselect_all() doesn't deselect the root TreeItem (Godot 4 Beta 12).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants