-
-
Notifications
You must be signed in to change notification settings - Fork 793
Description
What is the problem or limitation you are having?
The Canvas widget is has no keyboard handling. It would be useful to be able to do things like scroll a plot using arrow keys or capture simple keyboard input for games.
Describe the solution you'd like
Add a callback for keyboard events on the Canvas widget. The callback should be given the key pressed as a Toga Key expression, along with any modifiers, and ideally the text that results from that key combination with the current keyboard layout, if any.
Describe alternatives you've considered
Leaving it as is, and implementing a more robust input handling system at a higher level that is independent of the Canvas widget. For example the proposal doesn't handle composed keys or entering text in Chinese/Japanese/Korean. These require additional special handling which should be its own subsystem (see eg. hoe Gtk handles composing characters).
Additional context
This is related to #3994 in so far as the Canvas element can have keypress handlers. Looking at how HTML/Javascript handles key presses may give a guide to the information that is passed to the callback.