airstruck / luigi

Lovely User Interfaces for Game Inventors
MIT License
113 stars 23 forks source link

Text widget should not trap any keypresses it doesn't use. #40

Closed airstruck closed 8 years ago

airstruck commented 8 years ago

For example, if another widget has a shortcut of 'z', pressing 'z' in the text widget should type a 'z' into the widget and not activate the other widget (current behavior as of latest commit). But, if another widget has a shortcut of 'escape' the text widget shouldn't trap this, since the text widget doesn't use that key.

In other words, keypresses not associated with text input should be allowed to propagate (unless the text widget has special handling for them, like 'ctrl-c').

From https://wiki.libsdl.org/CategoryKeyboard

SDL_Keycode values are mapped to the current layout of the keyboard and correlate to an SDL_Scancode. Values of this type are used to represent key symbols in the key.keysym.sym field of the SDL_Event structure, among other places. The values in the SDLKeycode enumeration are based on Unicode values representing the unmodified character that would be generated by pressing the key, or the scancode value with the high bit set (bitwise ORed with 0x40000000) for those keys that do not generate characters. Keycode constants use the symbol name (lowercased for letters) prefixed with SDLK (eg: SDLK_SPACE).

Under the SDL backend, we should be able to test for that high bit and let the event propagate if it's present, or if any modifiers keys besides 'shift' were pressed. Not sure whether it's possible to test for that high bit under Love, or if a workaround exists.