pub struct ContextMenu { /* private fields */ }Expand description
A right-click-anchored popup menu attached to a Response.
See the module-level docs for usage. The menu opens at the cursor
position when target is secondary-clicked.
Implementations§
Source§impl ContextMenu
impl ContextMenu
Sourcepub fn new(id_salt: impl Hash) -> Self
pub fn new(id_salt: impl Hash) -> Self
Create a context menu keyed by id_salt. The salt scopes the
popup’s open/closed state in egui memory and must be stable for
the target it’s attached to.
Sourcepub fn min_width(self, min_width: f32) -> Self
pub fn min_width(self, min_width: f32) -> Self
Minimum width of the popup in points. Default: 200.
Sourcepub fn show<R>(
self,
target: &Response,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> Option<R>
pub fn show<R>( self, target: &Response, add_contents: impl FnOnce(&mut Ui) -> R, ) -> Option<R>
Render the context menu attached to target. The popup opens on
secondary-click on target at the pointer position; clicking
inside an item, clicking outside, or pressing Esc closes it.
Returns Some(R) with the body closure’s return value while the
menu is open, None while closed.
Trait Implementations§
Source§impl Clone for ContextMenu
impl Clone for ContextMenu
Source§fn clone(&self) -> ContextMenu
fn clone(&self) -> ContextMenu
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 moreAuto Trait Implementations§
impl Freeze for ContextMenu
impl RefUnwindSafe for ContextMenu
impl Send for ContextMenu
impl Sync for ContextMenu
impl Unpin for ContextMenu
impl UnsafeUnpin for ContextMenu
impl UnwindSafe for ContextMenu
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