Button Control Type
This topic provides information about Microsoft UI Automation support for the Button control type.
A button is an object that a user interacts with to perform an action such as the OK and Cancel buttons on a dialog box. The button control is a simple control to expose because it maps to a single command that the user wishes to complete.
The following sections define the required UI Automation tree structure, properties, control patterns, and events for the Button control type. The UI Automation requirements apply to all button 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 button 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|
The following table lists the UI Automation properties whose value or definition is especially relevant to the controls that implement the Button control type (such as button controls). For more information about UI Automation properties, see Retrieving Properties from UI Automation Elements.
|UI Automation Property||Value||Notes|
|UIA_AcceleratorKeyPropertyId||See notes.||A button control typically supports an accelerator key to enable the end user to quickly perform the action represented by the button from the keyboard.|
|UIA_AutomationIdPropertyId||See notes.||The value of this property must be unique among all peer elements in the raw view of the UI Automation tree.|
|UIA_BoundingRectanglePropertyId||See notes.||The outermost rectangle that contains the whole control.|
|UIA_ClickablePointPropertyId||See 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_HelpTextPropertyId||See notes.||The help text should indicate what the end result of activating the button will be. This is typically the same type of information presented through a tooltip.|
|UIA_IsContentElementPropertyId||TRUE||The button control must always be content.|
|UIA_IsControlElementPropertyId||TRUE||The button control must always be a control.|
|UIA_IsKeyboardFocusablePropertyId||See notes.||If the control can receive keyboard focus, it must support this property.|
|UIA_LabeledByPropertyId||Null||Button controls are self-labeled by their contents.|
|UIA_LocalizedControlTypePropertyId||See notes.||Localized string corresponding to the Button control type. The default value is "button" for en-US or English (United States).|
|UIA_NamePropertyId||See notes.||The name of the button control is the text used to label it. Whenever an image is used to label a button, alternate text must be supplied for the button's Name property.|
Required Control Patterns
The following table lists the UI Automation control patterns required to be supported by all button controls. For more information on control patterns, see UI Automation Control Patterns Overview.
|Control Pattern/Pattern Property||Support/Value||Notes|
|IExpandCollapseProvider||See notes.||When a button is hosted as a child of a split button, the child button can support the ExpandCollapse control pattern instead of the Invoke or Toggle control pattern. The ExpandCollapse control pattern can be used for opening or closing a menu or other sub-structure associated with the button element.|
|IInvokeProvider||See notes.||All buttons should support the Invoke control pattern or the Toggle control pattern but not both. The Invoke control pattern must be supported when the button performs a command at the request of the user. This command maps to a single operation such as Cut, Copy, Paste, or Delete.|
|IToggleProvider||See notes.||All buttons should support the Invoke control pattern or the Toggle control pattern but not both. The Toggle control pattern must be supported if the button can cycle through a series of up to three states. Typically this is seen as an on/off switch for specific features.|
The following table lists the UI Automation events that button 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_Invoke_InvokedEventId||If 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_NamePropertyId property-changed event.|
|UIA_ToggleToggleStatePropertyId property-changed event.||If the control supports the Toggle control pattern, it must support this event.|