NSMenu

管理应用菜单的对象。

定义

  1. class NSMenu : NSObject

主题

管理菜单栏

返回一个布尔值,该值指示菜单栏是否可见。

设置菜单栏是否可见并是否可被用户选择。

主菜单的菜单栏高度(以像素为单位)。

创建一个NSMenu对象

初始化并返回一个具有指定标题且启用了菜单项自动启用功能的菜单。

添加和删除菜单项

将菜单项插入菜单中的指定位置。

Creates and adds a menu item at a specified location in the menu.

Adds a menu item to the end of the menu.

Creates a new menu item and adds it to the end of the menu.

Removes a menu item from the menu.

Removes the menu item at a specified location in the menu.

Invoked when a menu item is modified visually (for example, its title changes).

Removes all the menu items in the menu.

查找菜单项

Returns the first menu item in the menu with the specified tag.

Returns the first menu item in the menu with a specified title.

Returns the menu item at a specific location of the menu.

The number of menu items in the menu, including separator items.

An array containing the menu items in the menu.

查找菜单项的索引

Returns the index identifying the location of a specified menu item in the menu.

Returns the index of the first menu item in the menu that has a specified title.

Returns the index of the first menu item in the menu identified by a tag.

Returns the index of the first menu item in the menu that has a specified action and target.

Returns the index of the first menu item in the menu that has a given represented object.

Returns the index of the menu item in the menu with the given submenu.

管理子菜单

Assigns a menu to be a submenu of the menu controlled by a given menu item.

The action method assigned to menu items that open submenus.

The parent menu that contains the menu as a submenu.

启用和禁用菜单项

指示菜单是否自动启用和禁用其菜单项。

根据NSMenuValidation非正式协议启用或禁用菜单的菜单项,并在必要时调整菜单大小以适合其当前菜单项。

获取和设置菜单字体

The font of the menu and its submenus.

处理键盘等效项

对与给定键等效的菜单项执行操作。

模拟鼠标点击

使应用程序将指定菜单项的操作消息发送到其目标。

管理标题

The title of the menu.

配置菜单大小

The minimum width of the menu in screen coordinates. var size: NSSize

The size of the menu in screen coordinates

获取菜单属性

The available properties for the menu.

显示上下文菜单

Indicates whether the pop-up menu allows appending of contextual menu plug-in items.

显示上下文相关帮助

Displays a contextual menu over a view for an event.

Displays a contextual menu over a view for an event using a specified font.

Pops up the menu at the specified location.

管理状态列的显示

Indicates whether the menu displays the state column.

处理高亮

Indicates the currently highlighted item in the menu.

管理用户界面

配置菜单中菜单项的布局方向。

管理Delegate

The delegate of the menu.

处理跟踪

Dismisses the menu and ends all menu tracking.

Dismisses the menu and ends all menu tracking without displaying the associated animation.

常量

These constants are used as a bitmask for specifying a set of menu or menu item properties, and are contained by the propertiesToUpdate property.

通知

Posted after a menu item is added to the menu.

Posted after a menu item in the menu changes appearance.

Posted when menu tracking begins.

Posted when menu tracking ends, even if no action is sent.

Posted after a menu item is removed from the menu.

Posted just after the application dispatches a menu item’s action method to the menu item’s target.

Posted just before the application dispatches a menu item’s action method to the menu item’s target.

初始化