zng

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§

Enums§

Statics§

Functions§