pub struct MenuCloseAutoFocusGuardPolicy {
pub prevent_on_outside_press: bool,
pub prevent_on_focus_outside: bool,
pub prevent_on_escape: bool,
}Expand description
Policy for suppressing close auto-focus based on how a menu overlay was dismissed.
This is primarily intended to prevent “focus stealing” in non-modal menu overlays where outside presses are click-through: the pointer-down may legitimately interact with underlay UI, and restoring focus back to the trigger would fight that.
Fields§
§prevent_on_outside_press: boolPrevent close auto-focus when dismissed via an outside press.
prevent_on_focus_outside: boolPrevent close auto-focus when dismissed due to focus moving outside the dismissible layer.
prevent_on_escape: boolPrevent close auto-focus when dismissed via Escape.
Implementations§
Source§impl MenuCloseAutoFocusGuardPolicy
impl MenuCloseAutoFocusGuardPolicy
Sourcepub fn for_modal(modal: bool) -> Self
pub fn for_modal(modal: bool) -> Self
Default policy for Radix-style menu overlays.
- Modal overlays (
modal=true) are not click-through, so outside presses generally should not suppress focus restoration. - Non-modal overlays (
modal=false) are click-through, so outside presses should suppress close auto-focus to avoid stealing focus back to the trigger.
Sourcepub fn prevent_always() -> Self
pub fn prevent_always() -> Self
Always prevent close auto-focus.
pub fn prevent_on_escape(self, prevent: bool) -> Self
Trait Implementations§
Source§impl Clone for MenuCloseAutoFocusGuardPolicy
impl Clone for MenuCloseAutoFocusGuardPolicy
Source§fn clone(&self) -> MenuCloseAutoFocusGuardPolicy
fn clone(&self) -> MenuCloseAutoFocusGuardPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl PartialEq for MenuCloseAutoFocusGuardPolicy
impl PartialEq for MenuCloseAutoFocusGuardPolicy
Source§fn eq(&self, other: &MenuCloseAutoFocusGuardPolicy) -> bool
fn eq(&self, other: &MenuCloseAutoFocusGuardPolicy) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for MenuCloseAutoFocusGuardPolicy
impl Eq for MenuCloseAutoFocusGuardPolicy
impl StructuralPartialEq for MenuCloseAutoFocusGuardPolicy
Auto Trait Implementations§
impl Freeze for MenuCloseAutoFocusGuardPolicy
impl RefUnwindSafe for MenuCloseAutoFocusGuardPolicy
impl Send for MenuCloseAutoFocusGuardPolicy
impl Sync for MenuCloseAutoFocusGuardPolicy
impl Unpin for MenuCloseAutoFocusGuardPolicy
impl UnsafeUnpin for MenuCloseAutoFocusGuardPolicy
impl UnwindSafe for MenuCloseAutoFocusGuardPolicy
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
Mutably borrows from an owned value. Read more