Re: [gtk-list] Use of optionmenu's



Aslak Johansen wrote:

> I am trying to figure out how to see which option is selected
> in an gtk_option_menu.
> There must be a simple way to do so!

I had the same thought exactly last week. The best way I've found to handle
the problem (and it's more of a gross hack than a solution), is to connect a
function to the "activate" signal of each item of the option menu.
Make that function then set a global variable to a value that you as the
programmer know represents one of the items in your option menu.
When you need to know what has been selected, just examine your global
variable.

It's dirty, it's global, and it's down-right unpleasant, imho.
But it does work.

You can retrieve the selected "menuitem" itself using
gtk_menu_get_selected() (or a similar named function, i don't have the
reference docs to hand).
But how you extract the actual name of the item from what is returned, I
don't know.

As a plea to the gtk+ developers, please consider making a nicer option menu
API in the next major version of gtk+... Please?

Regards,

Lee.




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