-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add add_item method to Tree Node #708
Comments
After trying to implement this, it seems that |
I understand that for your problem it had a workaround, but can we reopen this issue? I would like to move Anyway,
How can I properly reuse it later then? |
As for the new APIs, there is an approved PR that may interest you already: godotengine/godot#46773 |
I think it should be
How can I move
|
The issue is still present. You can't reuse TreeItems after removing them from the Tree. You can't add them back to the Tree. |
Please open a new proposal based on the API used in 4.0.beta1, as this proposal refers to the old 3.x API (which won't get significant new features on its own, only backwards-compatible backports). |
Describe the project you are working on:
GUI based app where markers can be added and organized into a tree structure, displayed in a Tree node. Each marker contains some information that gets serialized to a json file on save. Originally I used an ItemList and array to store the markers but now I want the user to be able to organize them into groups using a Tree node.
Describe the problem or limitation you are having in your project:
Tree has the method
create_item
which creates and returns a TreeItem object. While this works well, I have extra information I want to store in each TreeItem. To do this, I'd like to subclass TreeItem usingextends TreeItem
, add my properties, and use the custom class almost exactly how I would a normal TreeItem. I cannot add a custom type to my Tree node however sincecreate_item
creates a TreeItem node for me, instead of allowing me to use a custom type.Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Add another method to the Tree class called
add_item
which works very similar tocreate_item
but has a parameter to pass in an instance of a custom type that extends TreeItem.Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Something like this, may or may not work, I just altered the current
create_item
method real quick:If this enhancement will not be used often, can it be worked around with a few lines of script?:
Those who don't need this functionality can continue to use Tree just as they have before. It doesn't break any current projects.
Is there a reason why this should be core and not an add-on in the asset library?:
I'm not sure there is any workaround in pure GDScript and it is very simple to implement in the engine.
I'm willing to work on this and submit a PR, just wanted to make sure there was no GDScript solution and that this was a good way to go about this.
The text was updated successfully, but these errors were encountered: