Treeview#15
Conversation
There was a problem hiding this comment.
I am sorry it took me a long time to review this given my other priorities, like https://github.com/AndyObtiva/glimmer-dsl-libui (which I gave a workshop on in RubyConf 2023: https://github.com/AndyObtiva/how-to-build-desktop-applications-in-ruby), https://github.com/AndyObtiva/glimmer-dsl-wx , and https://github.com/AndyObtiva/glimmer-dsl-web
I finally got a chance to review the code and test hello_treeview.rb, and I added some feedback.
| grid sticky: 'nsew', row_weight: 1, column_weight: 1 | ||
| show 'tree' | ||
| selectmode 'browse' | ||
| selection <=> [tree_data, :selection] |
There was a problem hiding this comment.
I tested this, and I appreciate that you had the selection data-binding infer options automatically just like we do with lists.
I added this code to the model to do the printout:
def selection=(value)
@selection = value
pd @selection
endpd (https://github.com/AndyObtiva/puts_debuggerer) is similar to puts, but prints more information like the file name and line number, and uses ap (awesome print), so I like to use it for debugging when I am not using a real debugger.
When I printed the selection value from the model selection= method though, I was expecting to see only a single string representing the node that was selected. Instead, I got an array. Also, if I clicked deep in the tree, I got an array and a nested hash, not just the selected node string.
Printout:
[PD] samples/hello/hello_treeview.rb:22
> pd @selection
=> []
[PD] samples/hello/hello_treeview.rb:22
> pd @selection
=> [
[0] "Item 1"
]
[PD] samples/hello/hello_treeview.rb:22
> pd @selection
=> [
[0] "Item 2"
]
[PD] samples/hello/hello_treeview.rb:22
> pd @selection
=> [
[0] "Tree 1"
]
[PD] samples/hello/hello_treeview.rb:22
> pd @selection
=> [
[0] {
"Tree 1" => [
[0] "Subitem 1"
]
}
]
[PD] samples/hello/hello_treeview.rb:22
> pd @selection
=> [
[0] {
"Tree 1" => [
[0] "Subitem 2"
]
}
]
[PD] samples/hello/hello_treeview.rb:22
> pd @selection
=> [
[0] {
"Tree 1" => [
[0] "Subtree 1"
]
}
]
[PD] samples/hello/hello_treeview.rb:22
> pd @selection
=> [
[0] {
"Tree 1" => [
[0] {
"Subtree 1" => [
[0] "And so on..."
]
}
]
}
]
For the basic top-level nodes, it seemed strange to return an array like ['item1']. I would have expected to just get item1. For the deeper levels, I would have also expected to get a single string too, like "And so on...".
I am curious, is there a reason why you implemented tree selection data-binding that way? Is that how you use the data in your applications?
No description provided.