pub struct ContextMenuState { /* private fields */ }Expand description
Manages context menu state
Tracks the currently active menu, hover state, and handles click detection. Only one context menu can be active at a time.
Implementations§
Source§impl ContextMenuState
impl ContextMenuState
Sourcepub fn open_for_widget(
&mut self,
position: (f64, f64),
items: Vec<ContextMenuItem>,
widget: WidgetId,
)
pub fn open_for_widget( &mut self, position: (f64, f64), items: Vec<ContextMenuItem>, widget: WidgetId, )
Sourcepub fn get_active(&self) -> Option<&ContextMenuRequest>
pub fn get_active(&self) -> Option<&ContextMenuRequest>
Get the current menu rectangle
Sourcepub fn set_hovered(&mut self, index: Option<usize>)
pub fn set_hovered(&mut self, index: Option<usize>)
Sourcepub fn get_hovered(&self) -> Option<usize>
pub fn get_hovered(&self) -> Option<usize>
Sourcepub fn handle_click(&mut self, index: usize) -> Option<String>
pub fn handle_click(&mut self, index: usize) -> Option<String>
Handle a click on a menu item
Returns the item ID if the item is enabled and was clicked successfully. Returns None if the item is disabled or out of bounds.
§Example
ⓘ
if let Some(item_id) = menu.handle_click(0) {
match item_id.as_str() {
"copy" => copy_to_clipboard(),
"paste" => paste_from_clipboard(),
_ => {}
}
menu.close();
}Sourcepub fn item_count(&self) -> usize
pub fn item_count(&self) -> usize
Trait Implementations§
Source§impl Clone for ContextMenuState
impl Clone for ContextMenuState
Source§fn clone(&self) -> ContextMenuState
fn clone(&self) -> ContextMenuState
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 Debug for ContextMenuState
impl Debug for ContextMenuState
Source§impl Default for ContextMenuState
impl Default for ContextMenuState
Source§fn default() -> ContextMenuState
fn default() -> ContextMenuState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ContextMenuState
impl RefUnwindSafe for ContextMenuState
impl Send for ContextMenuState
impl Sync for ContextMenuState
impl Unpin for ContextMenuState
impl UnsafeUnpin for ContextMenuState
impl UnwindSafe for ContextMenuState
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