pub struct PopupOptions {
pub parent: AnyWindowHandle,
pub anchor_rect: Bounds<Pixels>,
pub anchor: PopupAnchor,
pub gravity: PopupGravity,
pub constraint_adjustment: PopupConstraintAdjustment,
pub offset: Point<Pixels>,
pub grab: bool,
}Expand description
Options for a parent-anchored popup window such as a menu, dropdown, context menu or tooltip.
A popup is placed relative to an anchor rectangle on its parent window rather than at an absolute screen position. The platform resolves the final position, so this works both on systems where the compositor owns window placement (Wayland) and on platforms with absolute coordinates.
The popup’s size comes from WindowOptions::window_bounds, whose
origin is ignored. All coordinates are in logical pixels.
Fields§
§parent: AnyWindowHandleThe window the popup is anchored to.
anchor_rect: Bounds<Pixels>The rectangle the popup is positioned relative to, in the parent window’s coordinate space (the same space element bounds are in). For example, a dropdown menu uses the bounds of the button that opened it.
anchor: PopupAnchorWhich point of Self::anchor_rect the popup is anchored to.
gravity: PopupGravityThe direction in which the popup extends away from the anchor point. A dropdown that
drops below its button anchors to PopupAnchor::BottomLeft with a gravity of
PopupGravity::BottomRight so it grows down and to the right.
constraint_adjustment: PopupConstraintAdjustmentHow the platform may adjust the popup if the requested placement would put it off-screen.
offset: Point<Pixels>An additional offset applied to the popup after anchoring.
grab: boolWhether the popup should take an explicit input grab.
Grabbing popups behave like menus: they take keyboard focus and are dismissed when the user clicks outside of them or presses a dismissing key. Use it for menus and comboboxes, not for tooltips or other passive popups.
A grab must be requested while the triggering input is still active, in practice the press of the mouse button that opens the popup. Open grabbing popups from a mouse-down handler rather than a click handler, otherwise the grab is refused.
Automatic dismissal only covers input aimed at other applications. A click elsewhere in your own application still reaches it as usual, so closing the popup in that case is up to you. Nested grabbing popups must be closed in the reverse order they were opened.
Trait Implementations§
Source§impl Clone for PopupOptions
impl Clone for PopupOptions
Source§fn clone(&self) -> PopupOptions
fn clone(&self) -> PopupOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PopupOptions
impl Debug for PopupOptions
impl Eq for PopupOptions
Source§impl PartialEq for PopupOptions
impl PartialEq for PopupOptions
impl StructuralPartialEq for PopupOptions
Auto Trait Implementations§
impl Freeze for PopupOptions
impl RefUnwindSafe for PopupOptions
impl Send for PopupOptions
impl Sync for PopupOptions
impl Unpin for PopupOptions
impl UnsafeUnpin for PopupOptions
impl UnwindSafe for PopupOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more