Skip to main content

eject_interaction_on_disable

Function eject_interaction_on_disable 

Source
pub fn eject_interaction_on_disable(
    commands: Commands<'_, '_>,
    newly_disabled: Query<'_, '_, Entity, Added<Disabled>>,
    tracker: ResMut<'_, FocusTracker>,
    tinted: Query<'_, '_, (&mut Visuals, &mut StyleOverrides)>,
    focus_visibles: Query<'_, '_, (), With<FocusVisible>>,
    focusables: Query<'_, '_, (Entity, &TabIndex, Option<&DocumentOrder>), Without<Disabled>>,
    tab_info: Query<'_, '_, (&TabIndex, Option<&DocumentOrder>)>,
    parents: Query<'_, '_, &ChildOf>,
    visibles: Query<'_, '_, &Visible>,
    styles: Query<'_, '_, &Style>,
)
Expand description

The moment an entity gains Disabled (spec section 0: runtime enable/disable via bind-disabled), strip every live interaction state from it:

  • Hovered / Pressed are removed (with their transient tween components) - the hover tint / press tint end immediately, and a pending release will not click (dispatch_clicks requires Pressed). The tinted fill is let go of at once, so the :disabled swap lands on the true idle style.
  • Keyboard focus moves to the next focusable in tab order (same (TabIndex, DocumentOrder) ordering cycle_focus_on_tab uses, wrapping; hidden and disabled entities skipped), or clears when the disabled entity was the only focusable. The FocusVisible marker travels with the focus if it was present.