| View previous topic :: View next topic |
| Author |
Message |
Osiris
Joined: 17 Dec 2005 Posts: 65
|
Posted: Sun Jan 22, 2006 7:52 pm Post subject: How to implement double-clicks for TreeStore? |
|
|
Hello,
today's question is, how to implement a functionality for TreeStore, that a double click expand the Tree, to show the next level?
Or do I have not seen this in docs?
Greetings
Christian |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Sun Jan 22, 2006 8:53 pm Post subject: Re: How to implement double-clicks for TreeStore? |
|
|
| Osiris wrote: | | today's question is, how to implement a functionality for TreeStore, that a double click expand the Tree, to show the next level? |
See the PEAR package Gtk2_VarDump. I implemented that for a single-click there. |
|
| Back to top |
|
 |
kingrs
Joined: 15 Jan 2006 Posts: 30 Location: Stafford, UK
|
|
| Back to top |
|
 |
karlbowden
Joined: 18 Dec 2005 Posts: 21 Location: Taree, NSW, Australia
|
Posted: Sun Jan 22, 2006 11:40 pm Post subject: |
|
|
Hey Osiris,
I had to find the same thing too.
Here's two bits of code straight out of the working program, but you'll have to rewrite my code to fit your program, but it should put you on the right path.
The true or false on the expand_row function is wether to expand all children too.
| Code: | $this->tree_view->connect ('button_press_event', array ($this, 'tree_view_buttonpress'));
|
| Code: | function tree_view_buttonpress ($widget, $event) {
// Get currently selected items:
list ($model, $iter) = $widget->get_selection ()->get_selected ();
if (!$iter) {
return;
}
$info = $model->get_value ($iter, 0);
if ($event->button == 1 && $event->type == 5) {
// Button == 1 // leftclick
// type == 5 // doubleclick
if ($info['type'] == 'submenu') {
if ($this->tree_view->row_expanded ($model->get_path ($iter)))
$this->tree_view->collapse_row ($model->get_path ($iter));
else
$this->tree_view->expand_row ($model->get_path ($iter), false);
}
else {
echo "not submenu\n";
}
}
}
|
|
|
| Back to top |
|
 |
|