Re: [gtk-list] Wanted: CList with Popup menu sample code



This is in Perl, but it works:

$clist = new Gtk::CList;
$clist->signal_connect('button_press_event', \&event_handler);
$mc_popup=new Gtk::Menu;


sub event_handler {
  my ($widget, $event) = @_;
  if ($event->{button} == 3) {
   $mc_popup->popup(undef,undef,$event->{button},1);
  }
return 1;
}

Granted, I didn't populate the list, or the menu, but I assume you know how to do that.
In case you don't speak perl, the concept is pretty simple, attach a signal handler to the
button_press_event on the CList.  Have you signal handler check the "button" value of the
Gtk::Event structure that you get from the signal.  If the button value equals 3 (ie: right click)
then activate the popup method on your Gtk::Menu.

For complete perl source on how to do this and more, check into CSCMail at
http://www.cyberdeck.org/cscmail

If you need C source for the popup, I would recommend looking at the source code
for Spruce.  (This is where I learned how to do a right-click popup menu myself)

-Steve


> Hi,
> 
> after some putzing around, I'm still having trouble creating a clist which
> displays a popup window when an item in the CList is selected. If anybody
> knows of some sample code which does this, I'd appreciate a pointer ..
> 
> Thanks a lot
> --> Robert
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]