Window Menu Bar

The window menu bar sits directly below the title bar and is part of the window client area: it takes up height at the top of the page, and page content starts below its bottom edge. JadeView draws it natively, not as page DOM, so page styles and scrolling do not affect it.

For field meanings and icon rules, see Menu API; for page context menus, see Page Context Menu.

Scope

SettingApplies to
jade_window_set_menuOne window; takes precedence.
jade_set_application_menuEvery normal window without its own menu; windows created later inherit it too.
Neither callNormal windows show the built-in default menu (Edit / View / Window / Help).
C
int32_t jade_set_application_menu(const JadeMenuItemDesc* items, uint32_t item_count);
int32_t jade_window_set_menu(uint32_t window_id, const JadeMenuItemDesc* items,
                             uint32_t item_count);

Both return 1 when the request is queued and 0 when it is rejected; query jade_last_error_code() / jade_last_error_message() for the reason.

Rules and limits

  • Top-level entries must be submenus (kind = 1); any other type rejects the whole call.
  • item_count = 0 hides the menu bar; NULL, 0 works as well.
  • The menu bar height follows its content and scales with the system DPI. It needs no manual height and does not consume title bar height.
  • The menu bar hides automatically in full screen and comes back on exit.
  • Windows without window decorations never attach the application menu automatically: that includes title_bar_style set to BarOverlay or hidden, and noframe = 1. To give such a window a menu bar, call jade_window_set_menu for that window.

Example

C
JadeMenuItemDesc bar[] = {
    { "file",      NULL,   "File", NULL,    1, 0, { 0 } },
    { "file-new",  "file", "New", "Ctrl+N", 0, 0, { 0 } },
    { "file-open", "file", "Open", "Ctrl+O", 0, 0, { 0 } },
    { "file-quit", "file", "Exit", NULL,    0, 0, { 0 } },
    { "view",      NULL,   "View", NULL,    1, 0, { 0 } },
    { "view-full", "view", "Full Screen", "F11", 0, 0, { 0 } },
};

if (!jade_set_application_menu(bar, 6)) {
    const char* message = jade_last_error_message(); /* e.g. a top-level entry is not a submenu */
}

Replace the menu for a single window only:

C
jade_window_set_menu(window_id, bar, 6);

Events

Selecting an item emits menu-command with {"item_id":"..."}; the source ID is the owning window. See Event Types for registration and callbacks.

Compared with popup menus

ItemWindow menu barPopup menu
Entry pointjade_set_application_menu / jade_window_set_menujade_menu_popup
PositionFixed below the title barFollows the cursor or given coordinates
LayoutConsumes height at the top of the pageFloats above the page, no layout impact
LifetimeStays until replaced or hiddenCloses on selection or dismissal