Menu Control Type
This topic provides information about Microsoft UI Automation support for the Menu control type.
A menu control allows hierarchal organization of elements associated with commands and event handlers. In a typical Microsoft Windows application, a menu bar contains several menu buttons (such as File, Edit, and Window), and each menu button displays a menu. A menu contains a collection of menu items (such as New, Open, and Close), which can be expanded to display additional menu items or to perform a specific action when clicked.
The following sections define the required UI Automation tree structure, properties, control patterns, and events for the Menu control type. The UI Automation requirements apply to all menu controls where the UI framework/platform integrates UI Automation support for control types and control patterns.
This topic contains the following sections.
Typical Tree Structure
The following table depicts a typical control and content view of the UI Automation tree that pertains to menu controls and describes what can be contained in each view. For more information about the UI Automation tree, see UI Automation Tree Overview.
|Control View||Content View|
Menu controls always appear in the control view and the content view of the UI Automation tree. Menu controls should appear under the control that their information is referring to. UI Automation clients can listen for UIA_MenuOpenedEventId to ensure that they consistently obtain information conveyed by menu controls. Context menu controls are a special case. They may appear as children of the desktop or of a top level application window.
A menu control can contain other controls, such as edit controls and combo boxes, within its structure. These additional controls correspond to the "other controls" listed in the previous table in the control and content views.
The following table lists the UI Automation properties whose value or definition is especially relevant to the Menu control type. For more information about UI Automation properties, see Retrieving Properties from UI Automation Elements.
|UI Automation Property||Value||Notes|
|UIA_IsContentElementPropertyId||TRUE||The menu control is always included in the content view of the UI Automation tree.|
|UIA_IsControlElementPropertyId||TRUE||The menu control is always included in the control view of the UI Automation tree.|
|UIA_LabeledByPropertyId||NULL||No label is anticipated with a typical menu control.|
|UIA_NamePropertyId||See notes.||The menu control does not require a Name property to be set, or it could have the same name as the associated control, such as a menu item that opened the submenu.|
Required Control Patterns
There are no required control patterns for the Menu control type.
Menu controls must raise the UIA_MenuOpenedEventId event when they appear on the screen. The UIA_MenuOpenedEventId event will include the text of the control. The UIA_MenuClosedEventId event must be raised when a menu disappears from the screen.
The following table lists the UI Automation events that menu controls are required to support. For more information on events, see UI Automation Events Overview.
|UI Automation Event||Notes|
|UIA_BoundingRectanglePropertyId property-changed event.|
|UIA_IsEnabledPropertyId property-changed event.||If the control supports the IsEnabled property, it must support this event.|
|UIA_IsOffscreenPropertyId property-changed event.||If the control supports the IsOffscreen property, it must support this event.|