How to enable and disable an action? #599
Replies: 2 comments
-
I think you're right. Relm4 should at least expose the |
Beta Was this translation helpful? Give feedback.
-
Ok, now we have |
Beta Was this translation helpful? Give feedback.
-
How can you dynamically enable and disable a RelmAction?
Context
I'm trying to create a GUI for an application that allows a user to open a file, edit specific values in it, and save the file.
I have created two actions, one for opening a file and one for saving a file:
And registered them in a
RelmActionGroup
:Because of the type of file the application is meant to edit, it does not make sense to allow the user to save a file if they have not already opened a file. So I would like to disable the save action until the user opens a file.
How can I disable and enable the save action?
Things I've looked into
The api docs for relm4::actions::RelmAction mention that it wraps around gio::SimpleAction. The docs for gio::SimpleAction list a
set_enabled
method that looks like the functionality I'm looking for, however I have not been able to figure out a way to access the underlying gio::SimpleAction for a RelmAction.https://docs.rs/relm4/latest/relm4/actions/struct.RelmAction.html
https://relm4.org/docs/stable/gio/struct.SimpleAction.html
I also tried seeing if there are any methods for RelmAction or RelmActionGroup, but I didn't see any that would allow me to disable an action or access the underlying gio::SimpleAction (without moving the action group like in
RelmActionGroup::into_action_group
).Beta Was this translation helpful? Give feedback.
All reactions