logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: accessing selected item from OptionMenu: msg#00124

Subject: Re: accessing selected item from OptionMenu
On Fri, Jun 27, 2003 at 06:34:37PM +0100, Chris Phillips wrote:
> > you didn't mention whether you were using gtk-perl or gtk2-perl, so i've
> > answered for both.
> 
> sorry, gtk2 of course... thought you might have rememebered me from a few 
> days ago... 
>  
> > gtk+-2.x adds the incredibly useful gtk_option_menu_get_history function. 
> > recall that gtk_option_menu_set_history has always been the way to set which
> > item in the menu is selected --- get_history tells you the index of the one
> > that is selected.
> > 
> > so, in gtk2-perl, that would be INTEGER = $optionmenu->get_history.
> 
> erm... ok... i'm already *using* set_history... i feel stupid - no suprise 
> there then. that is only the position though, not the label string or any 
> other data associated with the item.

You can get the menu of an optionmenu.  I use this bit of code:

    my $menu = $optionmenu->get_menu;
    my $data = $menu->get_active->get_data('data') if ($menu);

get_active() gives you the menu item, and I set some user-data on it to
indicate what the item represents.

> 
> as for the ItemFactory use, I got as far as getings signals through the 
> entries, and finally gave up when I kept getting invalid path errors for 
> the accelgroup... nevermind.
> 
> thanks
> 
> chris
> _______________________________________________
> gtk-perl-list mailing list
> gtk-perl-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-perl-list

-- 
René Seindal (rene@xxxxxxxxxx)                  http://sights.seindal.dk/



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>