Export (0) Print
Expand All

MenuItem Control Type

This topic provides information about Microsoft UI Automation support for the MenuItem control type.

A menu control allows hierarchal organization of elements associated with commands and event handlers. In a typical Windows application, a menu bar contains several menu items (such as File, Edit, and Window), and each menu item 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 perform a specific action when clicked.

The following sections define the required UI Automation tree structure, properties, control patterns, and events for the MenuItem control type. The UI Automation requirements apply to all menu item 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 item controls and describes what can be contained in each view. For more information about the UI Automation tree, see UI Automation Tree Overview.

Control ViewContent View
  • MenuItem "Help"
    • Menu (submenu of Help menu item)
      • MenuItem "Help Topics"
      • MenuItem "About Notepad"
  • MenuItem "Help"
    • MenuItem "Help Topics"
    • MenuItem "About Notepad"

 

The control view of the menu item control has the UI Automation tree structure shown above. Note that the menu item for Help on the menu bar has been added to better illustrate the structure.

For the content view, Menu is absent from the UI Automation tree because it does not convey meaningful information to the end user.

Relevant Properties

The following table lists the UI Automation properties whose value or definition is especially relevant to the MenuItem control type. For more information about UI Automation properties, see Retrieving Properties from UI Automation Elements.

UI Automation PropertyValueNotes
UIA_AutomationIdPropertyIdSee notes.The value of this property must be unique among all peer elements in the raw view of the UI Automation tree. Allocate the AutomationId property for a menu item if the element is known to be consistent across different instances of the user interface. If the menu item is dynamically populated and not predictable, leave the AutomationId property blank.
UIA_BoundingRectanglePropertyIdSee notes.The outermost rectangle that contains the whole control.
UIA_ClickablePointPropertyIdSee notes.Supported if there is a bounding rectangle. If not every point within the bounding rectangle is clickable, and the element performs specialized hit testing, override and provide a clickable point.
UIA_ControlTypePropertyIdMenuItem
UIA_IsContentElementPropertyIdTRUEThe menu item control is always included in the content view of the UI Automation tree.
UIA_IsControlElementPropertyIdTRUEThe menu item control is always included in the control view of the UI Automation tree.
UIA_IsKeyboardFocusablePropertyIdSee notes.If the control can receive keyboard focus, it must support this property.
UIA_LocalizedControlTypePropertyIdSee notes.Localized string corresponding to the MenuItem control type. The default value is "menu item" for en-US or English (United States).
UIA_NamePropertyIdSee notes.The name of the menu item control is the text used to label it.

 

Required Control Patterns

The following table lists the UI Automation control patterns required to be supported by menu item controls. For more information on control patterns, see UI Automation Control Patterns Overview.

Control PatternSupportNotes
IExpandCollapseProvider DependsIf the control can be expanded or collapsed, implement IExpandCollapseProvider.
IInvokeProvider DependsIf the control executes a single action or command, implement IInvokeProvider.
ISelectionItemProvider DependsIf the control is used to select from a list of options among menu items, implement ISelectionItemProvider.
IToggleProvider DependsIf the control represents an option that can be turned on or off, implement IToggleProvider.

 

Required Events

The following table lists the UI Automation events that menu item controls are required to support. For more information on events, see UI Automation Events Overview.

UI Automation EventNotes
UIA_AutomationFocusChangedEventId
UIA_BoundingRectanglePropertyId property-changed event.
UIA_ExpandCollapseExpandCollapseStatePropertyId property-changed event.If the control supports the ExpandCollapse control pattern, it must support this event.
UIA_Invoke_InvokedEventIdIf the control supports the Invoke control pattern, it must support this 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.
UIA_SelectionItem_ElementAddedToSelectionEventIdIf the control supports the SelectionItem control pattern, it must support this event.
UIA_SelectionItem_ElementRemovedFromSelectionEventIdIf the control supports the SelectionItem control pattern, it must support this event.
UIA_SelectionItem_ElementSelectedEventIdIf the control supports the SelectionItem control pattern, it must support this event.
UIA_StructureChangedEventId
UIA_ToggleToggleStatePropertyId property-changed event.If the control supports the Toggle control pattern, it must support this event.

 

Legacy Issues

For Microsoft Win32 menu items, the Toggle control pattern is supported only when a menu item is checked and it is possible to programmatically determine whether support for the Toggle control pattern is required. Because a Win32 menu item does not expose whether it can be checked, the Invoke control pattern is supported when the menu item is not checked. The Invoke control pattern is always supported, even for menu items that are only required to support the Toggle control pattern. This is so clients do not become confused when a menu item that was supporting the Invoke control pattern (when the menu item was unchecked) no longer supports that pattern when it becomes checked.

Related topics

Conceptual
UI Automation Control Types Overview
UI Automation Overview

 

 

Community Additions

ADD
Show:
© 2014 Microsoft