-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Convert keypad movement events to equivalent non-keypad ones. #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Eliot Blennerhassett <[email protected]>
thonny/tktextext.py
Outdated
| for i in kmap: | ||
| def mfunc(event, key=i): | ||
| self.event_generate(kmap[key], **{'state': event.state}) | ||
| self.bind(i, mfunc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Windows it gives me _tkinter.TclError: bad event type or keysym "KP_Left". Numpad left keycode is just Left in Windows. You should catch and silence the binding errors.
I'm also worried that on some platforms this approach may generate double movement actions (one for KP_Left and another for generated Left). The standard approach is ending the event handler with return "break" -- this should stop the event propagation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please add link to the issue as comment inside bind_keypad!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a new pull request rebased and squashed onto current master branch.
|
Thank you for the contribution! Please see my comments in the code! |
|
BTW. Do you have IDLE installed? Does your numpad movement keys work there? Which Tk version do you have? ("Thonny => Help => About" and "IDLE => Help => About IDLE") |
Just installed, and no, numpad movement doesn't work there either.
Python 3.7.3, Tk 8.6.9 |
(I expect this to be squashed into previous) Signed-off-by: Eliot Blennerhassett <[email protected]>
Signed-off-by: Eliot Blennerhassett <[email protected]>
(doesn't really belong in this PR, but causing CI to fail)
|
Thanks! I'll test it in my Ubuntu at work. |
Improves experience for users that only have numpad/keypad movement keys, lacking standalone versions of same.