Skip to main content

dismiss_popups_on_outside_press

Function dismiss_popups_on_outside_press 

Source
pub fn dismiss_popups_on_outside_press(
    presses: MessageReader<'_, '_, PointerPressed>,
    hovered: Query<'_, '_, Entity, With<Hovered>>,
    panels: Query<'_, '_, (Entity, &PopupPanel)>,
    headers: Query<'_, '_, &DropdownButton>,
    parents: Query<'_, '_, &ChildOf>,
    store: ResMut<'_, PropertyStore>,
)
Expand description

Close any open PopupPanel when a primary press lands outside both the panel’s own subtree and (for dropdowns) its trigger header.

Reads PointerPressed and the entity currently under the cursor (Hovered, maintained by lumen_input::hit_test). A press over empty space clears the cursor target, so it dismisses every open panel. Pressing the dropdown header is treated as inside so the header’s own toggle (tabs::dispatch_dropdown_clicks, which fires on release) stays authoritative and the panel doesn’t close-then-reopen.