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§
- Default
Style WPopup default style.- POPUP
- Popup service.
- Popup
WAn overlay container.- Popup
Close Requested Args - Arguments for
POPUP_CLOSE_REQUESTED_EVENT.
Enums§
- Context
Capture - Defines if a
Popup!captures the build/instantiation context. - Popup
Close Mode - Optional parameter for
POPUP_CLOSE_CMD. - Popup
State - 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 PDefines the popup placement and size for popups open by the widget or descendants.- close_
delay PDelay awaited before actually closing when popup close is requested.- close_
on_ focus_ leave PPopup behavior when it loses focus.- context_
capture PDefines if the popup captures the local context to load in the popup context.- is_
close_ delaying PIf close was requested for this layered widget and it is just awaiting for theclose_delay.- on_
popup_ close_ requested PClosing popup event.- on_
pre_ popup_ close_ requested PPreviewon_popup_close_requestedevent.- style_
fn PExtends or replaces the widget style.