Fix Issue #378
Fix Issue #378
#399 in iced-rs/iced_aw — merged 2026-01-02
Background
Issue #378: Buttons inside the ContextMenu overlay do not show hover states.
Summary of Key Changes
Created a new MenuButton widget specifically designed for menus and overlays that:
- Explicitly manages hover state - Tracks hover in its update() method by directly checking cursor.is_over(bounds)
- Draws its own background - Renders hover effects directly in draw() instead of relying on iced's styling system
Files Modified/Created
- Created: src/menu_button.rs - The new widget
- Modified: src/widget.rs - Added module export
- Modified: src/lib.rs - Added public export
- Modified: Cargo.toml - Added menu_button feature
- Modified: examples/context_menu.rs - Updated to use MenuButton
- Modified: src/widget/overlay/context_menu.rs - Fixed warning
Usage
use iced_aw::MenuButton;
MenuButton::new(text("Menu Item"))
.on_press(Message::ItemClicked)
.width(Length::Fill)
.padding(8.0)
- Updated Example
- Modified examples/context_menu.rs to use MenuButton (Right-click on "right click me!" and hover over the menu items - you should now see hover highlights.)
- Updated integration tests
- Modified: tests/context_menu_integration_tests.rs
- Created: tests/menu_button_integration_tests.rs
# test
cargo test --lib widget::menu_button::tests && cargo test --test menu_button_integration_tests
# example
cargo build --example context_menu --features menu_button,context_menu
Last updated 2026-05-14
Links to this note
Credits
Merged pull requests, newest first.