Menu

#1161 menu -type menubar breaks kbd navigation

closed-invalid
5
2002-08-14
2002-03-15
Joe English
No

Keyboard navigation to menus with <Alt-Keypress> raises
an error if the menu is configured with -type menubar,
as the following script demonstrates:

#--cut here
package require Tk
menu .menubar -type menubar
menu .file
.file add command -label Exit -underline 1 -command
[list destroy .]
.menubar add cascade -label File -underline 0 -menu
.file
. configure -menu .menubar

pack [label .l -text "Press Alt-F"] \ -expand true -fill both -padx 200 -pady 200

#-- cut here

This raises an error:

grab failed: window not viewable
grab failed: window not viewable
while executing
"grab -global $w"
(procedure "tk::TraverseToMenu" line 21)
invoked from within
"tk::TraverseToMenu . f"
(command bound to event)

Without '-type menubar', keyboard navigation works OK.

Discussion

  • Todd Helfter

    Todd Helfter - 2002-05-07
    • status: open --> open-accepted
     
  • Todd Helfter

    Todd Helfter - 2002-05-07

    Logged In: YES
    user_id=92123

    I agree your demo script creates the same error for me.

     
  • Joe English

    Joe English - 2002-06-11

    Logged In: YES
    user_id=68433

    I suspect that the correct fix for this problem is "Don't Do
    That" -- that is, users should not specify [menu ... -type
    menubar] in the first place.

    menu(n) sez:
    Command-Line Name:-type [...]
    This option can be one of menubar, tearoff, or
    normal, and is set when the menu is created. [...] this
    does not affect the menu widget's behavior. This is used
    by the cloning mechanism *and is not normally set outside
    of the Tk library*.

    (emphasis added). Can anyone confirm or deny this?

     
  • Joe English

    Joe English - 2002-08-14

    Logged In: YES
    user_id=68433

    > I suspect that the correct fix for this problem is "Don't
    Do That" [...]

    After further investigation, I'm pretty sure this is the
    right fix. The menu '-type' option should only be set by
    the Tk internals, not in user code.

    Closing the bug.

     
  • Joe English

    Joe English - 2002-08-14
    • status: open-accepted --> closed-invalid