useMenuBar function

Module @runic-artifex/react in @runic-artifex/react 0.23.0

function useMenuBar(options?: UseMenuBarOptions): MenuBarHandle;

Follows the window's declared menu bar (Runic Desktop's DesktopMenuBarPresentation.Page) while the component is mounted, as headless state for the application's own menubar component, through createMenuBarController. Pass invoke to the component's item onSelect/onClick and map onRequest to it. A changed shortcuts or keyboard creates a new controller; unmounting disposes it. The server snapshot is connecting.

const menuBar = useMenuBar({ onRequest: request => request.kind === "open" ? setOpen(request.menu.key) : focusBar() });
if (menuBar.state.placement !== "page") return null;
menuBar.state.menus.map(menu => <Menubar.Menu key={menu.key}>…</Menubar.Menu>)