Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MenuWrapper

src/widgets/menu_wrapper.rs

Purpose

A container widget that positions menu popup content relative to a triggering button, with a backdrop overlay that handles click-outside-to-close.

How It Works

┌─────────────────────────────────────┐
│  Backdrop (transparent overlay)     │
│                                     │
│          ┌──────────────┐           │
│          │  Menu Content│           │
│          │  (positioned │           │
│          │   relative   │           │
│          │   to button) │           │
│          └──────────────┘           │
│                                     │
│  Click anywhere on backdrop = close │
└─────────────────────────────────────┘

The MenuWrapper:

  1. Renders a fullscreen backdrop (semi-transparent or transparent)
  2. Positions the menu content horizontally aligned with the triggering button
  3. Positions the menu vertically above or below the bar (depending on bar position)
  4. Handles click events on the backdrop to close the menu

Integration

The App::menu_wrapper() method creates the MenuWrapper for the currently open menu:

#![allow(unused)]
fn main() {
fn menu_wrapper(&self, output: &ShellInfo, menu_type: &MenuType, button_ui_ref: &ButtonUIRef)
    -> Element<Message>
{
    let content = match menu_type {
        MenuType::Settings => self.settings.menu_view(&self.theme),
        MenuType::Updates => self.updates.menu_view(&self.theme),
        // ...
    };

    MenuWrapper::new(content, button_ui_ref, bar_position, menu_size)
        .on_backdrop_press(Message::CloseMenu(output.id))
}
}

The wrapper uses predefined size categories for menu width:

SizeWidth
Small250px
Medium350px
Large450px
XLarge650px