pub fn cast_spell<S: SpellAssociated + Debug>(
waywindow: S,
state: Option<State>,
set_callback: Option<Box<dyn FnMut(State)>>,
) -> Result<(), Box<dyn Error>>👎Deprecated since 1.0.2: Use macro cast_spell instead. It will be removed in release 1.0.3.
Expand description
This is the primary function used for starting the event loop after creating the widgets, setting values and initialising windows. Example of the use can be found here. The function takes in the following function arguments:-
- Wayland side of widget corresponding to it’s slint window.
- A instance of struct implementing ForeignController. This will be wrapped in
ArcandRwLockas it would be used across threads internally, if the widget is static in nature and doesn’t need state that needs to be changed remotely via CLI. You can parse in None. - A callback which is called when a CLI command is invoked changing the value. The closure gets an updated value of your state struct. The common method is to take the updated value and replace your existing state with it to reflect back the changes in the slint code. If state is provided, then it is important for now to pass a callback corresponding to it too. You can use this callback for example.
move |state_value| {
let controller_val = state_value.read().unwrap();
let val = controller_val
.as_any()
.downcast_ref::<State>()
.unwrap()
.clone();
ui_clone.unwrap().set_state(val);
}
// here `ui_clone` is weak pointer to my slint window for setting back the `state` property.