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§
W
Popup default style.- Popup service.
W
An overlay container.- Arguments for
POPUP_CLOSE_REQUESTED_EVENT
.
Enums§
- Defines if a
Popup!
captures the build/instantiation context. - Optional parameter for
POPUP_CLOSE_CMD
. - Identifies the lifetime state of a popup managed by
POPUP
.
Statics§
- Close the popup.
- Closing popup event.
Functions§
P
Defines the popup placement and size for popups open by the widget or descendants.P
Delay awaited before actually closing when popup close is requested.P
Popup behavior when it loses focus.P
Defines if the popup captures the local context to load in the popup context.P
If close was requested for this layered widget and it is just awaiting for theclose_delay
.P
Closing popup event.P
Previewon_popup_close_requested
event.P
Extends or replaces the widget style.