pub struct DropdownMenu { /* private fields */ }Expand description
Dropdown menu component (shadcn/ui Dropdown Menu)
§Example
use armas_basic::components::DropdownMenu;
let resp = DropdownMenu::new("actions")
.show_ui(ui, |ui| ui.button("Actions"), |builder| {
builder.item("Cut");
builder.item("Copy");
builder.item("Paste");
builder.separator();
builder.item("Delete");
});
if let Some(idx) = resp.selected {
// Handle selection
}Implementations§
Source§impl DropdownMenu
impl DropdownMenu
Sourcepub const fn open(self, is_open: bool) -> Self
pub const fn open(self, is_open: bool) -> Self
Set the menu to be open (used internally for submenus).
Sourcepub const fn position(self, position: PopoverPosition) -> Self
pub const fn position(self, position: PopoverPosition) -> Self
Set the menu position
Sourcepub const fn item_height(self, height: f32) -> Self
pub const fn item_height(self, height: f32) -> Self
Set the height of each menu item row
Sourcepub fn show_ui(
self,
ui: &mut Ui,
trigger: impl FnOnce(&mut Ui) -> Response,
content: impl FnOnce(&mut MenuBuilder),
) -> DropdownMenuResponse
pub fn show_ui( self, ui: &mut Ui, trigger: impl FnOnce(&mut Ui) -> Response, content: impl FnOnce(&mut MenuBuilder), ) -> DropdownMenuResponse
Show with inline trigger widget. Open/close state managed automatically.
The trigger closure renders the trigger widget (e.g. a button).
Clicking it toggles the menu open/closed. The menu auto-closes on
selection or click-outside.
Sourcepub fn show_at(
self,
ctx: &Context,
anchor_rect: Rect,
is_open: bool,
content: impl FnOnce(&mut MenuBuilder),
) -> DropdownMenuResponse
pub fn show_at( self, ctx: &Context, anchor_rect: Rect, is_open: bool, content: impl FnOnce(&mut MenuBuilder), ) -> DropdownMenuResponse
Show the menu at a specific anchor rect with explicit open state.
Use this for context menus where there is no trigger widget — the caller controls when the menu is open (e.g. on right-click).
Sourcepub fn show(
&mut self,
ctx: &Context,
anchor_rect: Rect,
content: impl FnOnce(&mut MenuBuilder),
) -> DropdownMenuResponse
pub fn show( &mut self, ctx: &Context, anchor_rect: Rect, content: impl FnOnce(&mut MenuBuilder), ) -> DropdownMenuResponse
Show the menu anchored to a rect (internal, used by submenus and show_ui).
Trait Implementations§
Source§impl Clone for DropdownMenu
impl Clone for DropdownMenu
Source§fn clone(&self) -> DropdownMenu
fn clone(&self) -> DropdownMenu
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 DropdownMenu
impl RefUnwindSafe for DropdownMenu
impl Send for DropdownMenu
impl Sync for DropdownMenu
impl Unpin for DropdownMenu
impl UnsafeUnpin for DropdownMenu
impl UnwindSafe for DropdownMenu
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