About actions

Actions what NWG uses to do stuff on controls during the execution of the program. Actions are sent through the Ui, then the Ui dispatches the action to the targeted control. After execution of the action by the control, an ActionReturn is returned.

The max size of an Action/ActionReturn is 16 bytes. If the action arguments are bigger than 8 bytes, they are boxed. To keep the code readable, NWG has the nwg::actions::helper module to generate these complex actions.

For a list of all built-in actions see 5. List of actions .

Executing actions

To execute an action the exec(ID, action) -> Result<ActionReturn, Error> method must be used. The ActionReturn value returned depends on the action sent.

Arguments
Behaviour
Failures
Example
if let Ok(ActionReturn::Text(name)) = ui.exec("Name", Action::GetText) {
    let msg = nwg::actions::helper::message(
        "Hello!", format!("Hello {}!", name),
         MessageButtons::Ok, MessageIcons::None
    );
    ui.exec("MainWindow", msg).unwrap();
}