Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is this a bug or feature of ttk::treeview?

20 views
Skip to first unread message

Rich

unread,
May 15, 2011, 11:08:22 AM5/15/11
to
I have encountered an interesting action when selecting a group of
items in a ttk::treeview with the mouse, and I'm unsure if it is a bug
or feature.

Example code:

ttk::treeview .tree
pack .tree -side top

.tree insert {} end -id "Item 1" -text "Item 1"
.tree insert {} end -id "Item 2" -text "Item 2"
.tree insert {} end -id "Item 3" -text "Item 3"

.tree insert "Item 1" end -id "Item 1-1" -text "Item 1-1"
.tree insert "Item 1" end -id "Item 1-2" -text "Item 1-2"
.tree insert "Item 1" end -id "Item 1-3" -text "Item 1-3"

.tree insert "Item 2" end -id "Item 2-1" -text "Item 2-1"
.tree insert "Item 2" end -id "Item 2-2" -text "Item 2-2"
.tree insert "Item 2" end -id "Item 2-3" -text "Item 2-3"

This should produce a tree that looks something like this when every
element is "open":

* Item 1
@ Item 1-1
@ Item 1-2
@ Item 1-3
* Item 2
@ Item 2-1
@ Item 2-2
@ Item 2-3
* Item 3

Now, close both "Item 1" and "Item 2" such that the tree looks like
this:

* Item 1
* Item 2
* Item 3

Now, if I click on "Item 3" with the mouse to select it, and issue
".tree selection" I get back "Item 3" as the list of selected rows.

If I click on "Item 2" to select it, and issue ".tree selection" I
also get back "Item 2" as the selection list.

But, if I click on "Item 2" then hold down shift and click on "Item 3"
to select both "Item 2" and "Item 3", what is returned from ".tree
selection" is {Item 2} {Item 2-1} {Item 2-2} {Item 2-3} {Item 3} or
all the children of "Item 2".

My expectation if "Item 2" was closed is that clicking "Item 2" then
shift clicking "Item 3" to select the two rows is that ".tree
selection" should return {Item 2} {Item 3}. I.e., the -id names of
only the visible rows that are selected.

What I get instead is what I would expect had "Item 2" been open and I
clicked "Item 2" then shift clicked "Item 3" and all the children of
"Item 2" are highlighted because they are visible in the tree. In
this situation, given that the rows are visible, and become part of
the selection highlight, I would expect to get back all the children -
id's of "Item 2".

The ttk::treeview manpage does not document the expected behavior of a
multi-row select that encompasses rows containing children elements,
which is partly why I can not decide if this is a bug or feature. I
am leaning towards thinking bug but maybe there is some use for the
present functionality that I have not recognized yet.

Any ideas?


Matthias Kraft

unread,
May 17, 2011, 6:34:24 AM5/17/11
to
Rich wrote:
> I have encountered an interesting action when selecting a group of
> items in a ttk::treeview with the mouse, and I'm unsure if it is a bug
> or feature.

It's a feature, I would guess.

Click "Item 2", Shift-Click "Item 3" ->
% .tree selection


{Item 2} {Item 2-1} {Item 2-2} {Item 2-3} {Item 3}

... as observed, but ...

Click "Item 2", Ctrl-Click "Item 3" ->
% .tree selection
{Item 2} {Item 3}

I like it, but it needs documentation...
--
Matthias Kraft
Software AG, Germany

0 new messages