Toolbar and menu

Adding a menu to an nk window is accomplished using NkMenubarBegin(), NkMenuBeginLabel(), and NkMenuItemLabel(), among others. The only difficult step in setting up a menu is that we also need to add an appropriate layout for the bar and its items. It's important (in fact, mandatory) that the bar is in a layout where y=0, so we immediately add a new row layout using dynamic sizing with NkLayoutRowBegin(). Then, we push the cell size for this layout using NLayoutRowPush().

A menu item is opened using NkMenuBeginLabel() and we must check the return value for this function—0 means that the menu is hidden. If it returns a non-zero value then we should lay out the menu below the bar. We start a new dynamic row layout with a single ...

Get Hands-On GUI Application Development in Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.