pub fn dispatch_ui_event<T>(block: impl FnOnce() -> T) -> Option<T>Expand description
Dispatches a UI event in a proper snapshot context.
This is a convenience wrapper around run_in_mutable_snapshot that returns
Option<T> instead of Result<T, &str>.
§Example
ⓘ
// In a keyboard event handler:
dispatch_ui_event(|| {
text_field_state.edit(|buffer| {
buffer.insert("a");
});
});