Re: [gtk-list] Re: gtk_option_menu_set_menu() weirdness



I have seen a problem with option menus and set_history that I believe is
Jamie's point, though I'm not completely sure.

The problem I've seen is that sometimes when the user clicks on an option
menu, the item that comes up under the mouse pointer is not the same as the
item that was chosen in the menu. In other words, to use Jamie's example,
the menu contains items X, Y, and Z. The visible item is Y. Clicking on the
option menu should bring up the menu such that item Y is directly under the
mouse pointer. Instead, the menu pops up such that item X is directly under
the mouse pointer. This is both confusing and dangerous: the user can
accidentally select a different menu item just by clicking and releasing
quickly.

I think it is the case that this happens only when the visible item has been
set with gtk_option_menu_set_history, and does not happen after the user has
changed the selection explicitly. I haven't tracked this down, but I've
often intended to. It seems that the code that computes where to place the
popped-up menu is relying on some variable that gets set when the user
clicks but does not get set when gtk_option_menu_set_history is called. At
least, that would explain it, though that theory may be nonsense.

John


on 2/25/00 6:21 AM, Owen Taylor at otaylor@redhat.com wrote:

> 
> 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]