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

Treeview #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Treeview #15

wants to merge 1 commit into from

Conversation

Phaengris
Copy link
Contributor

No description provided.

Copy link
Owner

@AndyObtiva AndyObtiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]
Copy link
Owner

@AndyObtiva AndyObtiva Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
  end

pd (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?

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

Successfully merging this pull request may close these issues.

2 participants