The menu item does not appear when creating a menu in the Builder interface

In the interface builder, I added a menu item to the main menu. I can click on the menu and access its contents, however, the title of the menu item does not appear when the program starts.

The image shows the application and its menu above and below the application, as shown in IB. Please note that if there is a menu option "Calculate" in the menu in IB, the running application has a space in its menu.

+4
source share
1 answer

The menu bar contains NSMenuItem, which contains NSMenu. Both have a Title property. In Interface Builder, what you see on the menu bar is the name NSMenuItem. In the app you see the name NSMenu. If the NSMenu header is not set, you will see only an empty line, which you showed in the screenshot.

Click on a menu item in Interface Builder to display a sub menu. Then you can set the title.

alt textalt text

Note that in the Builder interface, if you drag the Menu Item into the menu bar, you will get NSMenuItem without NSMenu binding. I suspect what you did. You can drag Menu on top of NSMenuItem to add a menu to it, and then you can select the menu title correctly. If, instead of dragging and dropping the Menu Item you drag the Submenu Item , then the attached NSMenu is already present, and it will automatically update the title when changing the text in the menu bar.

+9
source

Source: https://habr.com/ru/post/1315356/


All Articles