Left being select and right being menu popup is very common for
applications. If we take a file manager as an example (I am reporting
what explorer does on win32 because that is what I have in front of
me, but should be similar for nautilus):
On an item
Left click: select item
ctrl left click: toggle selection on item
shift left click: select items between last selected item with click
or ctrl click, unselect all others
Not on an item:
Left click: unselect all items
ctrl left click, shift left click: do nothing
Right click on an already selected item: show menu
Right click on an unselected item: select that item, unselect other
items, show menu
ctrl right click anywhere: show menu
shift right click anywhere: select that item, unselect other items, show menu
Right click not on an item: unselect all items, show menu
ctrl right click or shift right click not on an item: show menu
If you want to check if a path is selected:
selection=treeview.get_selection()
path_selected = selection.path_is_selected(path).
-Chris
On Wed, 09 Feb 2005 08:48:07 -0800 (PST), Doug Quale <[EMAIL PROTECTED]> wrote:
> Abel Daniel <[EMAIL PROTECTED]> writes:
>
> > The FAQ entry 13.17 on popup menus in TreeViews
> > (http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.017.htp)
> > has the unfortunate feature that it forces the selection to be the row
> > that is clicked. (The line "treeview.set_cursor( path, col, 0)" )
> >
> > This means that if multiple selection is allowed in the Treeview, and
> > one selects multiple lines then right-clicks, the previous selection
> > is lost.
> >
> > Obviously this is not the right thing to do as other programs in this
> > situation change the selection as if a normal mouseclick with the same
> > modifier keys would have been pressed. (So if the ctrl is pressed,
> > they add that row, if shift is pressed, they select the rows between
> > the two clicks, etc.)
> >
> > How should I implement that?
> >
> > The current version works if no modifier-keys are pressed.
> > Handling ctrl correctly is pretty easy.
> > The bigger problem is shift. It seems to me that the accepted meaning
> > of shift-click in a list is "select all rows between this and the
> > place of last click". How could I get the place of the last event?
> >
> > Would it be easier if I would simply generate a fake left-click event
> > with the right modifier keys? How could I do this?
>
> That's a good observation. The recipe in FAQ 13.17 doesn't work with
> multiple selections.
>
> Unfortunately I don't know how to do what you ask. Instead, I suggest
> cheating by making the problem much easier (trivial) and solving that.
>
> Instead of overloading right click to be select + pop up, how about
> selecting only with a left click and popping up only with right? On a
> right click, ignore the modifier keys (shift or ctrl) and test to see
> if there's a selection. If there's no selection then the popup needs
> something to work with, so use set_cursor() to select the row that was
> right clicked on like the FAQ entry does. If there is a selection
> then right click can just pop up the menu and work with the current
> selection without changing it. In addition to being much easier to
> implement, this might also be easier for the user to understand.
> Single selection + popup requires only a single right click. Multiple
> selection + popup can require on extra left click, but this doesn't
> seem burdensome.
> _______________________________________________
> pygtk mailing list [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
--
Christopher Lambacher
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/