Macro rat_focus::match_focus
source · macro_rules! match_focus { ($($field:expr => $block:expr),* $(, _ => $final:expr)?) => { ... }; }
Expand description
Does a match on the state struct of a widget. If
widget_state.is_focused() is true the block is executed.
There is a _ branch too, that is evaluated if none of the
given widget-states has the focus.
This requires that widget_state implements HasFocusFlag,
but that’s the basic requirement for this whole crate.
ⓘ
use rat_focus::match_focus;
let res = match_focus!(
state.field1 => {
// do this
true
},
state.field2 => {
// do that
true
},
_ => {
false
}
);
if res {
// react
}