Another macOS programming tutorial is here, and today we’re going to talk about a really interesting topic: Menus. Every macOS developer has to know about how to deal with menus, as they consist of a fundamental part on every application. Menus is the place where users access the app’s features and functionalities, and be sure that they always expect to find and use them.
Menus are parted by menu items, where a menu item is the actual option that gets clicked. Menu items can have single keys or key combinations assigned to them, so users can have access to the underlying functionality by just using their keyboard. There’s also a special item, the separator, which is just a horizontal line separating other menu items. Besides all that, menus can contain submenus which make it easy to group similar functionalities.
By default, each application comes with the main menu shown on the top bar of the macOS. Most of the menus you’ll be creating are going to exist there. However, there are also special menus, called context menus. A context menu is showing up when a UI control that has been assigned with such a menu is right-clicked or Ctrl-clicked. Menu options displayed there can be either unique to the context menu, or to be common to those available on the main menu.
When talking about menus, there is always another UI control tightly connected to them. That is the toolbar. The purpose of a toolbar is to provide users with access to important features of the app through buttons that can be found in a predefined, familiar place. Toolbars are not mandatory to exist in macOS apps, and they’re related to menus for one simple reason: Actionable toolbar items must always have equivalent menu items. If users hide the toolbar (because that’s something that can be done), then there should be no functionalities out of their reach.
We are going to see all the above in details through the upcoming parts of this tutorial. You’ll learn how to create menus both in Interface Builder and programmatically, you’ll get to know some best practices, and you’ll see how to deal with the toolbar. We’re just about to explore some really interesting stuff!