Replies: 1 comment
-
@kdwk I've created an issue from this discussion because I think it's definitely something that should be improved and discussions tend to be overlooked after some time. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The current way of adding actions and keyboard shortcuts for them is complicated and verbose. First, outside of the component one needs to declare an action group and action with macros, then in the fn init() of the component I need to get the main app, declare an action group (again), actually define the action, add the action to the action group, and attach the action group to a window.
Not only is this very troublesome, but it goes against the Relm model of handling inputs with the Input enum in fn update(), since actions bypass this mechanism. This also duplicates lots of code because many actions with keyboard shortcuts are also triggered with e.g. buttons in the UI, so the code needs to exist twice when one defines the action and in fn update().
Instead of the status quo, I would love to see actions being integrated with the Input enum or fn init(). Ideally, one should not need to declare any action or action group separately. Instead, either in the Input enum or fn update() one can attach the keyboard shortcut to the inputs.
e.g.
and Relm4 would automatically do the setting up of actions and actiongroups and attach the keyboard shortcut to the root of the component.
Beta Was this translation helpful? Give feedback.
All reactions