Skip to main content

apply_press_tint

Function apply_press_tint 

Source
pub fn apply_press_tint(
    commands: Commands<'_, '_>,
    tick: Res<'_, Tick>,
    anim: Res<'_, AnimationsActive>,
    pointer: Option<Res<'_, PointerState>>,
    tinted: Query<'_, '_, (Entity, &Interaction, &mut Visuals, &mut StyleOverrides, Option<&mut PressTween>, Option<&TransitionSpecs>, Has<Pressed>, Has<Hovered>), Or<(With<Pressed>, With<PressTween>)>>,
    orphaned: Query<'_, '_, (Entity, &mut Visuals, &mut StyleOverrides), (With<PressTween>, Without<Interaction>)>,
)
Expand description

Override the solid Visuals::fill with Interaction::press_tint while the entity is visually pressed. Tweens over PRESS_TWEEN_DURATION using ease-out.

Visually pressed = Pressed AND (currently over OR keyboard press): during a pointer press, Pressed doubles as the capture marker and survives the pointer dragging off the widget (spec section 0 rule 3), but the pressed visual must un-press while off and re-press on re-entry. “Currently over” is the Hovered marker (hit_test confines it to the captured entity mid-press); keyboard presses (Space FSM) have the primary button up and present pressed regardless of hover.

The press layer sits over the hover layer in StyleOverrides, so it blends from whatever the element shows under it, hover tint included, and a press released while still hovered fades back to the hover colour. Gradient-filled tiles are skipped (no animation path).