Re: [gtk-list] gtk_option_menu_set_menu() weirdness




Jamie Guinan <guinan@bluebutton.com> writes:

> Hi all,
> 
> The attached program creates a table with a button and an 
> option menu containing a menu with items "X", "Y", and "Z".
> It looks roughly like,
> 
>     -----------------
>     X_______________|
>     |               |
>     |  [Click me]   |   <-- Button
>     |               |
>     |  [  X   \/ ]  |   <-- Option menu
>     |               |
>      ---------------
> 
> 
> When I click the button, the callback calls menu_select() which
> changes the selected item in the option menu to the next item
> using gtk_option_menu_set_history().
> 
> But when I click on the right edge of the option menu (right of
> where the menu pops up), the popup menu gives the impression
> that the selected item is whatever it was at start time, or
> whatever I last set it to with the mouse.
> 
> For example, after one click, the app looks like this,
> 
>     -----------------
>     X_______________|
>     |               |
>     |  [Click me]   |
>     |               |
>     |  [  Y   \/ ]  |
>     |               |
>      ---------------
> 
> Then after a mouse click on the option menu, the popup looks
> like this,
> 
>     -----------------
>     X_______________|
>     |               |
>     |  [Click me]   |
>     |  [*X]         |
>     |  [ Y]   \/ ]  |
>     |  [ Z]         |
>      ---------------
> 
> Dragging the mouse around highlights different items, but
> after dragging over another widget it still looks like above.
> 
> It works "ok" in that it returns to "Y" if I click outside
> or hit ESC, but the appearance is very confusing.
> 
> Is this a bug, a feature, a mis-feature, or a programming
> error on my part?
> 
> $ gtk-config --version
> 1.2.5

Well, the big question in my mind is what is the '*' in your ascii
art... My best guess is that you might be using radio menu items in
your menu.

If that is the case, then that would explain your problem - I don't
think set_history, by itself, is going to switch the selected member
of the radio group. And also gives an easy solution: just use
regular menu items. An option menu is _already_ a user interface
for selecting one element from a group. You don't need radio menu
items.

The example in testgtk with the radio menu items in an option menu
is not supposed to be a UI suggestion. (That's the problem with
testgtk - it combines tests for weird situations where there were
bugs with more normal usage of widgets.)

Regards,
                                        Owen



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