Closed kchanqvq closed 3 years ago
Usual disclaimer: cl-bodge
is beta quality and heavily missing documentation - use it as a last resort.
I've looked into machinery. it is possible to extract modifiers for character input. I'll add them to character-input-event
.
Btw, if you don't need the whole engine, but only UI and 2D graphics, have a look at bodge-ui-window
Fixed in https://github.com/borodust/cl-bodge/commit/bb097277364a5e6a184de02b136f0787ead8f8e4
To inspect currently pressed (engaged/active) modifiers use cl-bodge.host:modifiers-from
on event. Modifiers for character input events should work too.
Sad news though is that not all modifier+key combinations trigger character input - this limitation is not something I can work around, because this event is just not triggered by underlying low-level layers.
I guess, solution coult be to bind both key and character callbacks and keep current modifiers somewhere, but another problem is bodge events are not guaranteed to fire in any certain thread and can actually be fired in parallel.
So only solid solution would be to use keys, not characters. I can expose key's scancode and/or glfwGetKeyName if that would be any help.
I used exactly that work around for now, listening for Escape/Meta/Alt/Control/Shift key press event and update global variables *some-modifier-PRESS*
.
Scancode is useful, but not strictly necessary for me now. I currently work around it using a stupid hash map from keywords to characters
Hi Pavel, thanks for the brilliant work!
I'm building a Lisp editor on top of
cl-bodge
but I'm a bit confused about how to handle key events incl-bodge
. In thetrivial-gamekit
source, one justdefine-event-handler
. However, this is a global effect but I'd like a application or widget specific handler. I tried(defmethod keyaction ((this my-app-class) key state))
but it's not doing anything. I also digged out an issue about `custom-widget-on-key-xx" but seems that it's not going down that direction afterwards.Also,
define-event-handler
specialized onkeyboard-event
receives fairly low level information (like when alt is pressed, and when alphanum key is pressed), butcharacter-input-event
doesn't give me any combination key (M-x
for example). Is there an existing mechanism suitable for reading combination key or I need to implement it myself?