Skip to main content

Popup

Struct Popup 

Source
pub struct Popup { /* private fields */ }
Expand description

A styled dropdown popup anchored to an arbitrary caller rectangle (e.g. a toolbar button), rather than the tray icon or a bare point. It reuses the exact place_popup math the tray uses; Tray, ContextMenu, and Popup differ only in how the anchor rectangle is obtained, and all funnel into one shared PopupSession (spec 01 §5.3, spec 20 §3).

Implementations§

Source§

impl Popup

Source

pub fn new(menu: Menu) -> Self

Create a dropdown popup from a Menu.

Source

pub fn options(self, options: MenuOptions) -> Self

Set popup options (width bounds, theme source).

Source

pub fn on_click(self, handler: impl Fn(&MenuId) + Send + 'static) -> Self

Register a click handler invoked with the activated row’s MenuId.

Source

pub fn menu(&self) -> &Menu

Borrow the menu.

Source

pub fn menu_options(&self) -> &MenuOptions

Borrow the options.

Source

pub fn accessibility_tree(&self) -> AxTree

Build the AxTree the platform screen reader walks over this menu.

Source

pub fn dispatch(&self, id: &MenuId)

Dispatch a click to the registered handler, if any. Fires the on_click closure first, then projects the activation onto the global MenuEvent channel (spec 03 §3) — so a Popup is a first-class event source alongside Tray and ContextMenu, as MenuEvent::receiver promises. An inert MenuId::none fires neither.

Source

pub fn anchored_to(&self, anchor: LogicalRect, edge: Edge) -> Result<()>

Show the popup anchored to anchor (a caller rectangle in screen logical coordinates), growing from edge, and block until it is dismissed.

This is the tray’s session anchored to an arbitrary rect instead of the tray icon (spec 20 §3). On platforms whose styled popup loop is not implemented yet this returns Error::Platform.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Popup

§

impl !Sync for Popup

§

impl !UnwindSafe for Popup

§

impl Freeze for Popup

§

impl Send for Popup

§

impl Unpin for Popup

§

impl UnsafeUnpin for Popup

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.