Loading...
Searching...
No Matches
ml::NativeMenuBar Class Reference

Native OS menu bar (macOS NSMenu / Windows HMENU). More...

#include <Malena/Graphics/Controls/NativeMenuBar.h>

Classes

struct  Item
class  Menu

Public Member Functions

 NativeMenuBar ()=default
 NativeMenuBar (const NativeMenuBar &)=delete
 ~NativeMenuBar ()
MenuaddMenu (const std::string &label)
 Add a top-level menu and return it for chaining.
void attach ()
 Build and attach the menu bar to the OS.
void detach ()
 Remove the menu bar and release platform resources.
NativeMenuBaroperator= (const NativeMenuBar &)=delete

Detailed Description

Native OS menu bar (macOS NSMenu / Windows HMENU).

Builds the platform menu from a simple C++ API, then attaches it to the application on macOS (global menu bar) or to the SFML window on Windows. On unsupported platforms, attach() is a no-op.

Usage

auto& file = menuBar.addMenu("File");
file.addItem("Open...", []{ openFile(); });
file.addItem("Save", []{ saveFile(); });
file.addSeparator();
file.addItem("Quit", []{ window.close(); });
auto& edit = menuBar.addMenu("Edit");
edit.addItem("Undo", []{ undo(); });
menuBar.attach(); // call once after building menus
Menu & addItem(const std::string &label, std::function< void()> action)
Add a clickable menu item with a callback.
Menu & addSeparator()
Add a horizontal separator line.
Native OS menu bar (macOS NSMenu / Windows HMENU).
void attach()
Build and attach the menu bar to the OS.
Menu & addMenu(const std::string &label)
Add a top-level menu and return it for chaining.
Note
attach() is a blocking configuration step; it does not suspend the event loop. On Windows, adding a menu bar slightly reduces the client-area height — account for this when sizing your content.

Definition at line 41 of file NativeMenuBar.h.

Constructor & Destructor Documentation

◆ NativeMenuBar() [1/2]

ml::NativeMenuBar::NativeMenuBar ( )
default

◆ ~NativeMenuBar()

ml::NativeMenuBar::~NativeMenuBar ( )

◆ NativeMenuBar() [2/2]

ml::NativeMenuBar::NativeMenuBar ( const NativeMenuBar & )
delete

Member Function Documentation

◆ addMenu()

Menu & ml::NativeMenuBar::addMenu ( const std::string & label)

Add a top-level menu and return it for chaining.

◆ attach()

void ml::NativeMenuBar::attach ( )

Build and attach the menu bar to the OS.

◆ detach()

void ml::NativeMenuBar::detach ( )

Remove the menu bar and release platform resources.

◆ operator=()

NativeMenuBar & ml::NativeMenuBar::operator= ( const NativeMenuBar & )
delete

The documentation for this class was generated from the following file: