From: Trevor W. <pha...@ic...> - 2017-05-01 03:04:31
|
All, I am seeing an issue with Tcl/Tk version 8.5.19 on Mac (I don’t see the same issue on X11) where assigning a keyboard shortcut to a main menu option (via the -accelerator option to the menu item), creating a bind statement to invoke the menu when the keyboard shortcut is used, and the using the keyboard shortcut causes the menu to be run twice. I have attached a test file which exhibits this issue. To run the test, run Wish, source the test file, place keyboard focus on the resulting text widget in the main window, and use the keyboard shortcut Control-Shift-. I have also seen this issue with Control-Shift-, (though I haven’t done any “exhaustive” testing to see what combinations of modifiers/symbols cause the double event and which do not). If you changed the keyboard shortcut to something like Command-n or something (and change the matching binding, of course), only one event would be generated (this is the expected behavior). In my limited amount of testing, it appears that the bind event gets run exactly once, but is the second event that is created. The first event seems to be coming from the fact that we added the -accelerator to the menu item (if I comment out the -accelerator line), only one event is created (the event created by the bind statement). The “workaround” to the issue seems to be not specifying and -accelerators but this makes for a terrible UI. According to the Tk menu documentation, -accelerator is only supposed to cause the bit of text to be added to the menu but should not cause anything else to happen. Any one have any ideas about this? Thanks, Trevor Williams |