You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've looked around for a while and have yet to find any existing documentation on how to implement keyboard/keypress events when building a gui with relm4. I tried a general search-engine, relm4's docs.rs, and the book published on relm4.org but they don't even include a reference to keyboard events.
I found some details on how to work with them directly in gtk4-rs from stackoverflow but I'm not sure how to integrate them into relm successfully so far.
I can see there was some discussion about implementation in the past (#548) but with little commentary. Would it possible to include a tutorial or basic description on how to implement them please?
Relm4 looks very promising for a project I'm working on at the moment but keyboard events are absolutely essential meaning all my effort will be for nil if I can't find a solution lol. Any help would be appreciated thanks!
The text was updated successfully, but these errors were encountered:
You're right, this topic is definitely lacking in our docs.
Depending on what you want to implement there are two mechanisms you can use:
If you want to add shortcuts to your app, you need to create and register so called "actions", which are basically callbacks that can be triggered by widgets or keyboard presses. After setting up and action, you can use set_accelerators_for_action to setup a keyboard shortcut that triggers the action: https://github.com/Relm4/Relm4/blob/main/examples/actions.rs#L68
If you want to get events for all key presses, you can add a EventControllerKey to a widget with add_controller. By connecting to the controllers key-pressed event, you should get an event for each key-press as long as the widget is in focus (I think if you use the main window, you should basically get all inputs).
@AaronErhardt, this is exactly what I'm looking for thank you! I can certainly get started on what I'm working on with this, so that's all I need.
I'm going to leave the issue open in case its of any use for a project tracker or anything but if you'd prefer to resolve it then feel free to close. Appreciate the response :)
I've looked around for a while and have yet to find any existing documentation on how to implement keyboard/keypress events when building a gui with relm4. I tried a general search-engine, relm4's docs.rs, and the book published on relm4.org but they don't even include a reference to keyboard events.
I found some details on how to work with them directly in gtk4-rs from stackoverflow but I'm not sure how to integrate them into relm successfully so far.
I can see there was some discussion about implementation in the past (#548) but with little commentary. Would it possible to include a tutorial or basic description on how to implement them please?
Relm4 looks very promising for a project I'm working on at the moment but keyboard events are absolutely essential meaning all my effort will be for nil if I can't find a solution lol. Any help would be appreciated thanks!
The text was updated successfully, but these errors were encountered: