From: Alexandre Ferrieux on 11 Feb 2010 12:29 On Feb 11, 4:32 pm, Óscar Fuentes <o...(a)wanadoo.es> wrote: > > I tried > > bind all <Key-F4> continue > > which blocks Alt-F4 on wish. But after your insistence, discovered that > > bind . <Key-F4> continue > > doesn't block Alt-F4. Note that this is perfectly in line with the documented algorithm, that I merely transcribed above: since the order of tags is ". Wish all", and the Alt-Key is defined on "all", then: (1) binding on "." won't interfere since it's another tag (no competition) (2) binding <Key-F4> on "all" will compete since it's the same tag, and win since it's more specific than Alt-Key (in some intuitive sense). > However, on a pristine wish instance: > (Oscar) 1 % bindtags . > . Wish all > (Oscar) 2 % bind . > (Oscar) 3 % bind Wish > (Oscar) 4 % bind all > <<PrevWindow>> <Key-Tab> <KeyRelease-F10> <Key-F10> <Alt-KeyRelease> > <Alt-Key> <KeyRelease-Alt_R> <Key-Alt_R> <KeyRelease-Alt_L> <Key-Alt_L> > > No binding for Alt-F4. So I can't explain why binding to `all' blocks > Alt-F4. Furthermore, can't explain why Alt-F4 works at all on a new wish > instance. Maybe some handling at the C level. Alt-Key on "all" is bound to the script: tk::TraverseToMenu %W %A which, given that Alt-F4 is a traversal alias for "Exit" in many apps, gives a good suspect for that deed ;-) In addition, note that an extra layer of handlers might blur (even more) the picture: Window managers in X. In my icewm for example, Alt-F4 is intercepted by the wm before Tk gets any chance... In that respect Windows looks like a clearer playground since the "window manager" there is less ambitious (handles only resizing, iconifying, and click-on-red-cross). Bottom line: don't bind to "all" if you fear unwanted tie-breaks by specificity. Just bind to the widget itself. Note that doing it only for toplevels works too, since the enclosing toplevel is always among the tags of an internal window. Alternatively, you can generate a new tag "everybody", hook all your handlers to it, and [bindtags] it to all widgets in the position just before "all", or even after if you don't fear the reverse effect (being shadowed by a default behavior). Please tell me if any dark spot remains. -Alex
From: Óscar Fuentes on 12 Feb 2010 08:09
Alexandre Ferrieux <alexandre.ferrieux(a)gmail.com> writes: > Note that this is perfectly in line with the documented algorithm, > that I merely transcribed above: since the order of tags is ". Wish > all", and the Alt-Key is defined on "all", then: > > (1) binding on "." won't interfere since it's another tag (no > competition) > (2) binding <Key-F4> on "all" will compete since it's the same tag, > and win since it's more specific than Alt-Key (in some intuitive > sense). I completely forgot that modifiers are also involved on the key matching process. [snip] > Bottom line: don't bind to "all" if you fear unwanted tie-breaks by > specificity. Following this advice solved a long standing bug on my application. [snip] > Please tell me if any dark spot remains. I think it is clear now. Thank you very much, Alex. |