Re: Attaching a menu to a clist row
| From: | Rich Payne | Date: | Thu, 06 Feb 2003 13:56:40 +0000 |
| Subject: | Re: Attaching a menu to a clist row | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-3011@lists.php.net to get a copy of this message | ||
On 6 Feb 2003, Aaron Bishell wrote:
> I have the following example menu:
>
> ...............................
>
> $menu=new GtkMenu();
>
> $menu_item1=new GtkMenuItem("menuitem 1");
> $menu_item1->connect("activate", "somefunction");
> $menu->append($menu_item1);
>
> $menu_item2=new GtkMenuItem("menuitem 2");
> $menu_item2->connect("activate", "somefunction2");
> $menu->append($menu_item2);
>
> ...............................
>
> How would I got about attaching this to a row on a clist so that when a
> user clicks right mouse button on a row the menu pops up? Im assuming id
> have to use something like "attach_to_widget()"?
$clist->connect('button_press_event',function_to_call,&$menu);
.....
function function_to_call ($widget,$event, $menu) {
// Find out if the user clicked the right button
if ($event->button == 3)
$menu->popup(null,null,null, $event->button, $event->time);
}
Hope that helps,
--rdp
Rich Payne
http://talisman.mv.com
rdp at talisman dot mv dot com