Trait zng_ext_input::focus::cmd::CommandFocusExt

source ·
pub trait CommandFocusExt {
    // Required methods
    fn focus_scoped(self) -> BoxedVar<Command>;
    fn focus_scoped_with(
        self,
        map: impl FnMut(Option<WidgetInfo>) -> CommandScope + Send + 'static,
    ) -> BoxedVar<Command>;
}
Expand description

Focus extension methods for commands.

Required Methods§

source

fn focus_scoped(self) -> BoxedVar<Command>

Gets a command variable with self scoped to the focused (non-alt) widget or app.

The scope is alt_return if is set, otherwise it is focused, otherwise the command is not scoped (app scope). This means that you can bind the command variable to a menu or toolbar button inside an alt-scope without losing track of the intended target of the command.

§Examples
let paste_in_focused_cmd = PASTE_CMD.focus_scoped();
let is_enabled = paste_in_focused_cmd.flat_map(|c| c.is_enabled());
paste_in_focused_cmd.get().notify();
source

fn focus_scoped_with( self, map: impl FnMut(Option<WidgetInfo>) -> CommandScope + Send + 'static, ) -> BoxedVar<Command>

Gets a command variable with self scoped to the output of map.

The map closure is called every time the non-alt focused widget changes, that is the alt_return or the focused. The closure input is the WidgetInfo for the focused widget and the output must be a CommandScope for the command.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl CommandFocusExt for Command

Implementors§