Function zng::widget::enabled

source ·
pub fn enabled(child: impl UiNode, enabled: impl IntoVar<bool>) -> impl UiNode
Expand description

P Defines if default interaction is allowed in the widget and its descendants.

This property sets the interactivity of the widget to ENABLED or DISABLED, to probe the enabled state in when clauses use is_enabled or is_disabled. To probe the a widget’s info state use WidgetInfo::interactivity value.

§Interactivity

Every widget has an interactivity state, it defines two tiers of disabled, the normal disabled blocks the default actions of the widget, but still allows some interactions, such as a different cursor on hover or event an error tooltip on click, the second tier blocks all interaction with the widget. This property controls the normal disabled, to fully block interaction use the interactive property.

§Disabled Visual

Widgets that are interactive should visually indicate when the normal interactions are disabled, you can use the is_disabled state property in a when block to implement the visually disabled appearance of a widget.

The visual cue for the disabled state is usually a reduced contrast from content and background by graying-out the text and applying a grayscale filter for images. Also consider adding disabled interactions, such as a different cursor or a tooltip that explains why the button is disabled.