command_property

Macro command_property 

Source
macro_rules! command_property {
    ($(
        $(#[$meta:meta])+
        $vis:vis fn $on_ident:ident $(< $on_pre_ident:ident $(, $can_ident:ident)? $(,)?>)? (
            $child:ident: impl $IntoUiNode:path,
            $handler:ident: $Handler:ty $(,)?
        ) -> $UiNode:path {
            $COMMAND:path
        }
    )+) => { ... };
}
Expand description

Declare command event properties.

Each declaration can expand to an on_cmd, on_pre_cmd and and optionally an can_cmd and CAN_CMD_VAR.

§Examples

command_property! {
    /// Property docs.
    #[property(EVENT)]
    pub fn on_paste<on_pre_paste>(child: impl IntoUiNode, handler: Handler<CommandArgs>) -> UiNode {
        PASTE_CMD
    }

    /// Another property, with optional `can_*` contextual property.
    #[property(EVENT)]
    pub fn on_copy<on_pre_copy, can_copy>(child: impl IntoUiNode, handler: Handler<CommandArgs>) -> UiNode {
        COPY_CMD
    }
}

The example above declares five properties and a context var. Note that unlike event_property! the body only defines the command, a standard node is generated.

§Enabled

An optional contextual property (can_*) and context var (CAN_*_VAR) can be generated. When defined the command handle enabled status is controlled by the contextual property. When not defined the command handle is always enabled.