Native OS menu bar (macOS NSMenu / Windows HMENU).
More...
#include <Malena/Graphics/Controls/NativeMenuBar.h>
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.
addItem(
"Quit", []{ window.close(); });
auto& edit = menuBar.
addMenu(
"Edit");
edit.
addItem(
"Undo", []{ undo(); });
- 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.
◆ NativeMenuBar() [1/2]
| ml::NativeMenuBar::NativeMenuBar |
( |
| ) |
|
|
default |
◆ ~NativeMenuBar()
| ml::NativeMenuBar::~NativeMenuBar |
( |
| ) |
|
◆ NativeMenuBar() [2/2]
| ml::NativeMenuBar::NativeMenuBar |
( |
const NativeMenuBar & | | ) |
|
|
delete |
◆ 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=()
The documentation for this class was generated from the following file: