Module popup

Module popup 

Source
Expand description

Popup widget and properties.

A popup is a temporary flyover inserted as a top-most layer using POPUP service. The service works as an extension of the LAYERS service that implements the concept of open and close and close requests. The Popup! widget is a styleable container that is a good popup root widget.

use zng::prelude::*;

let mut popup = None;
let is_closed = var(true);
Button! {
    layout::align = layout::Align::CENTER;
    child = Text!(is_closed.map(|&b| if b { "Open Popup" } else { "Close Popup" }.into()));
    on_click = hn!(|_| {
        if is_closed.get() {
            let p = POPUP.open(zng::popup::Popup! {
                child = Text!("Popup content!");
            });
            p.bind_map(&is_closed, |s| matches!(s, zng::popup::PopupState::Closed)).perm();
            popup = Some(p);
        } else if let Some(p) = popup.take() {
            POPUP.close(&p);
        }
    });
}

The example above declares a button that opens and closes a popup

Note that the toggle widget provides a combo style and the checked_popup property that implements a similar behavior.

§Full API

See zng_wgt_layer::popup for the full widget API.

Structs§

DefaultStyle
W Popup default style.
POPUP
Popup service.
Popup
W An overlay container.
PopupCloseRequestedArgs
Arguments for POPUP_CLOSE_REQUESTED_EVENT.

Enums§

ContextCapture
Defines if a Popup! captures the build/instantiation context.
PopupCloseMode
Optional parameter for POPUP_CLOSE_CMD.
PopupState
Identifies the lifetime state of a popup managed by POPUP.

Statics§

POPUP_CLOSE_CMD
Close the popup.
POPUP_CLOSE_REQUESTED_EVENT
Closing popup event.

Functions§

anchor_mode
P Defines the popup placement and size for popups open by the widget or descendants.
close_delay
P Delay awaited before actually closing when popup close is requested.
close_on_focus_leave
P Popup behavior when it loses focus.
context_capture
P Defines if the popup captures the local context to load in the popup context.
is_close_delaying
P If close was requested for this layered widget and it is just awaiting for the close_delay.
on_popup_close_requested
P Closing popup event.
on_pre_popup_close_requested
P Preview on_popup_close_requested event.
style_fn
P Extends or replaces the widget style.