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

[ENHANCMENT] TreeView selection control features #483

Open
EliteMasterEric opened this issue Oct 10, 2022 · 3 comments
Open

[ENHANCMENT] TreeView selection control features #483

EliteMasterEric opened this issue Oct 10, 2022 · 3 comments

Comments

@EliteMasterEric
Copy link
Contributor

When looking through the documentation and code for the TreeView component (which I am aware is experimental) I noticed that several missing features (or very poorly documented features) prevent the TreeView from being useful for user input, or anything more than display of a list of nodes.

The primary three I am looking for are:

  • Either property of TreeViewNode which determines whether it is the currently the selected item of its TreeView, or a property of TreeView which determines which item is selected (acting similarly to the ListView component)
  • A property of TreeViewNode which determines whether it is allowed to be the selected element of a TreeView.
  • An event callback for TreeView which triggers when an item is selected, and/or an event callback for TreeViewNode which triggers when it is selected.

The implementation of these three features would allow for user interaction with the TreeView to act as an input for the rest of the application, by allowing the user to select a node from the tree to "act upon".

A common use case for this feature would be a tree view which displays a directory structure, with the leaf nodes being individual files. The user could click on a leaf node to select a specific file.


As an aside, one potential additional feature (which I do not need for my application but may be needed in the future) is implementing the SelectionMode property on the TreeView, to allow the developer to define in what manner one (or more) list items may be selected, as seen in the ListView component.

switch (_listview.selectionMode) {

This may be a more complicated feature to implement, as multi-selection may have more advanced rules for a tree view (should the user only be allowed to multi-select nodes with the same parent? or only nodes on the same "level"?), so it might be better set aside as its own issue.

@ianharrigan
Copy link
Member

Either property of TreeViewNode which determines whether it is the currently the selected item of its TreeView, or a property of TreeView which determines which item is selected (acting similarly to the ListView component)

I think you are after .selectedNode on the treeview

A property of TreeViewNode which determines whether it is allowed to be the selected element of a TreeView.

Do you mean like a disabled property? I mean, all nodes are currently selectable.

An event callback for TreeView which triggers when an item is selected, and/or an event callback for TreeViewNode which triggers when it is selected.

TreeView should dispatch a UIEvent.CHANGE

@EliteMasterEric
Copy link
Contributor Author

I think you are after .selectedNode on the treeview
TreeView should dispatch a UIEvent.CHANGE

These should work, thank you. Sorry, I had trouble finding these things in the documentation. Maybe adding a simple trace() call to the UI explorer could be something to add to the list?

Also, does setting .selectedNode via code (to forcibly select an item) work?

Do you mean like a disabled property? I mean, all nodes are currently selectable.

Yes, I was thinking of doing selectable="false" but disabled makes sense too.

@ianharrigan
Copy link
Member

Also, does setting .selectedNode via code (to forcibly select an item) work?

Yeah, its bi directional... maybe i should start enhancing all the component explorer components with some more "options" rather than just "disable"... I mean, the test app for treeview (when i was working out its native counter part) was pretty comprehensive: https://community.haxeui.org/uploads/default/original/1X/d6937fecb3fcfde249b91b8dc54939a85f64421f.gif

Maybe i should start doing things like that in the component explorer also. Ill have a think about selectable, it might be a useful addition, im just not entirely sure when it would be useful (ie, disabled at least will give visual feedback that you cant do something).

Cheers,
Ian

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

No branches or pull requests

2 participants