From 2fb052d134cd3ebdf7648ca0a2ec554d449670e7 Mon Sep 17 00:00:00 2001 From: Hojjat Date: Wed, 2 Sep 2026 18:27:59 -0600 Subject: [PATCH] feat(context_menu): add item_width setter --- src/widget/context_menu.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/widget/context_menu.rs b/src/widget/context_menu.rs index c006ef01..b5cf6837 100644 --- a/src/widget/context_menu.rs +++ b/src/widget/context_menu.rs @@ -33,6 +33,7 @@ pub fn context_menu<'a, Message: 'static + Clone>( }), close_on_escape: true, window_id: window::Id::RESERVED, + item_width: ItemWidth::Uniform(240), on_surface_action: None, }; @@ -53,6 +54,8 @@ pub struct ContextMenu<'a, Message> { context_menu: Option>>, pub window_id: window::Id, pub close_on_escape: bool, + /// Width of each menu item, and therefore of the menu. + pub item_width: ItemWidth, #[setters(skip)] pub(crate) on_surface_action: Option Message + Send + Sync + 'static>>, @@ -116,7 +119,7 @@ impl ContextMenu<'_, Message> { click_outside: true, click_inside: true, }, - item_width: ItemWidth::Uniform(240), + item_width: self.item_width, item_height: ItemHeight::Dynamic(40), bar_bounds: bounds, main_offset: -(bounds.height as i32), @@ -503,7 +506,7 @@ impl Widget click_outside: true, click_inside: true, }, - item_width: ItemWidth::Uniform(240), + item_width: self.item_width, item_height: ItemHeight::Dynamic(40), bar_bounds: bounds, main_offset: 0,