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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.