Closed robertmlinden closed 6 years ago
This definitely doesn't sound right, and I'm not sure why it would happen. I'll need to have a look into it.
Could you post an example of code causing this problem, and also let me know your platform/python versions?
Simplifying...
self.bindKey("1", keyPress)
self.addMenuItem(... shortcut='Control-1' ...)
...
def keypress():
if key.isnumeric():
foo1()
Results: Menu Item 'Control-1' shortcut is non-responsive. Even when holding down the control key, foo1()
is called.
AppJar 0.93.0 Python 3.6.6 Windows
OK, I've done more digging.
Turns out the issue might be around the syntax Control-1
this doesn't create the expected binding, but instead (I think) is binding the mouse button?
Anyway, according to this: https://stackoverflow.com/questions/16082243/how-to-bind-ctrl-in-python-tkinter
You should be binding Control-Key-1
Closing this as I think it's resolved.
I've returned to this issue as it is once again relevant and the GUI is not responding to self.bindKey('Control-Key-1', [func])
. It's still activating the self.bindKey('1', [func2])
action. Not sure what's going on?
self.bindKey("1", self.key_press_home)
self.bindKey("Control-Key-1", self.launch_file_event_1)
key_press_home
is run instead of launch_file_event_1
Sorry to bother, I hope I'm not making a silly mistake.
Setting a general keybind (using
app.bindKey(key, func)
conflicts with setting ashortcut
for a menu item. That is, if a menu item shortcut is "Control-1" and a general keybind is "1", then everytime I hit "Control-1", first: the general keybind, "1", is activated (undesired), and then the shortcut keybind (yes, desired) is run.Keybinds need to recognize when they are hit with a special key.