Howdy all,
We've finally transitioned an open source project (Pure Data
http://puredata.info) from TK 8.4 to TK 8.5+ on macOS and have run into a couple problems that may be related to the Cocoa key event handling.
---
1. KeyRelease binding returns immediately
The PureData Tk GUI binds to all key press events for certain window types and forwards them to it's companion server for processing. Originally, when pressing a key a KeyPress is generated and then a KeyRelease after the key is released (as expected!). We're now noticing with the newer Tk versions, the KeyRelease happens immediately *after* the KeyPress.
Here's a minimal test:
~~~
package require Tk
bind . <KeyPress> {puts "press %K"}
bind . <KeyRelease> {puts "release %K"}
~~~
I created a ticket but have not heard anything:
https://core.tcl.tk/tk/tktview/1ba71a86bb6ab29180418ba4a25b0074e3c9de7a
More info can be found here:
https://github.com/pure-data/pure-data/issues/213
---
2. Shift key bindings on French keyboard mappings
The PureData Tk GUI uses MOD+SHIFT+key bindings which are also set as menu accelerators. This works fine with the English keyboard mapping. We're now running into issues with other keyboard locales, namely French so far, where the bindings with Shift result in the menu accelerator firing so it may be an issue with the menu event filtering.
For example, the "Bang" shortcut is bound as:
bind all <$::modifier-Shift-Key-B> {menu_send %W bng}
bind all <$::modifier-Shift-Key-b> {menu_send %W bng}
and the menu item:
$mymenu add command -label [_ "Bang"] -accelerator "$accelerator+Shift+B" \
-command {menu_send $::focused_window bng}
With the English keyboard mapping, the $::modifier-Shift-Key-b fires and the menu item's command is ignored (expected behavior).
With the French keyboard mapping, the $::modifier-Shift-Key-B fires AND the menu item command fires. It seems as though the capital B doesn't get matched to the menu accelerator binding.
The German keyboard mapping behaves the same as the English one.
-----
Dan Wilcox
danomatika.com
robotcowboy.com