Class CommandBarButton
Represents a button control in a menu, toolbar or in the ribbon
Inherited Members
Namespace: ABB.Robotics.RobotStudio.Environment
Assembly: ABB.Robotics.RobotStudio.Environment.dll
Syntax
public sealed class CommandBarButton : CommandBarControl
Remarks
For a toolbar or in the ribbon, this is a button. For a menu or context menu, this is a selectable menu item.
Constructors
CommandBarButton(String)
Creates a CommandBarButton with a specific ID.
Declaration
public CommandBarButton(string id)
Parameters
Type | Name | Description |
---|---|---|
String | id | Control Id |
Remarks
The Id can be null, which creates a button that can not will not be added to the UIEnvironment.CommandBarControls collection. If you specify an Id, prefix it with the name of your Add-In, to avoid conflicts.
See Also
CommandBarButton(String, String)
Creates a CommandBarButton with a specific ID and caption.
Declaration
public CommandBarButton(string id, string caption)
Parameters
Type | Name | Description |
---|---|---|
String | id | Control Id |
String | caption | Control caption |
Remarks
The ID can be null, which creates a button that will not be added
to the UIEnvironment.CommandBarControls collection.
If you specify an ID, prefix it with the name of your Add-In, to avoid conflicts.
See Also
CommandBarButton(String, String, Action<UpdateCommandUIEventArgs>, Action<ExecuteCommandEventArgs>)
Creates a CommandBarButton with a specific ID, caption and update/execute callbacks
Declaration
public CommandBarButton(string id, string caption, Action<UpdateCommandUIEventArgs> onUpdate, Action<ExecuteCommandEventArgs> onExecute)
Parameters
Type | Name | Description |
---|---|---|
String | id | |
String | caption | |
Action<UpdateCommandUIEventArgs> | onUpdate | |
Action<ExecuteCommandEventArgs> | onExecute |
Properties
Checked
This property is obsolete. Use DefaultChecked instead, or IsChecked to get the current state. This property may be removed in future versions.
Declaration
olete("Use DefaultChecked instead")]
public bool Checked { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
DefaultChecked
Gets or sets whether the button should be checked (pressed for toolbar items)
Declaration
public bool DefaultChecked { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
Instead of setting this property, it is also possible to use the UpdateCommandUI event (this will override the value of this property)
DefaultEnabled
Gets or sets whether the button should be enabled or disabled (grayed)
Declaration
public bool DefaultEnabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
Instead of setting this property, it is also possible to use the UpdateCommandUI event (this will override the value of this property)
DisplayAsCheckBox
Gets or sets whether the button should be displayed as a check box or not
Declaration
public bool DisplayAsCheckBox { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
This property will be ignored unless the button is placed directly on the Ribbon as a small button.
Enabled
This property is obsolete. Use DefaultEnabled instead, or IsEnabled to get the current state. This property may be removed in future versions.
Declaration
olete("Use DefaultEnabled instead")]
public bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Inert
Indicates that the button when added in a CommandBarGalleryPopup will appear enabled but not accept any input.
Declaration
public bool Inert { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
IsChecked
Returns true if the button is currently checked, taking both the DefaultChecked property and the UpdateCommandUI event into account. If any event handler for UpdateCommandUI sets its Checked property, then that value is returned, otherwise DefaultEnabled is returned.
Declaration
public bool IsChecked { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
This property reflects the behavior of the RobotStudio UI; if a button is checked in a menu or the ribbon, then this property will return true.
IsEnabled
Returns true if the button is currently enabled, taking both the DefaultEnabled property and the UpdateCommandUI event into account. If any event handler for UpdateCommandUI sets its Enabled property, then that value is returned, otherwise DefaultEnabled is returned.
Declaration
public bool IsEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
This property reflects the behavior of the RobotStudio UI; if a button is enabled in a menu or the ribbon, then this property will return true.
KeyboardShortcuts
Gets or sets an array of keyboard shortcuts to the command
Declaration
public Keys[] KeyboardShortcuts { get; set; }
Property Value
Type | Description |
---|---|
Keys[] |
LicenseFeature
Gets or sets a license feature required to execute this command.
Declaration
public string LicenseFeature { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
If the feature is not available, the button is disabled and the screen tip explains why. This should not be used as the only method to enforce the license, a proper license check should always be performed when the command is executed.
ResolveSubscriber
Gets or sets how the UpdateCommandUI and ExecuteCommand events are routed. If false, the events are sent to all subscribers. If true, the events are sent to the subscriber belonging to the visible window that was last active.
Declaration
public bool ResolveSubscriber { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
The default is true.
Methods
Execute()
Raises the ExecuteCommand event
Declaration
public void Execute()
Remarks
Can be used as a programmatic way of simulating e.g. a menu choice
Execute(ExecuteCommandReason)
Raises the ExecuteCommand event
Declaration
public void Execute(ExecuteCommandReason reason)
Parameters
Type | Name | Description |
---|---|---|
ExecuteCommandReason | reason |
Remarks
Can be used as a programmatic way of simulating e.g. a menu choice
ExecuteAsync(ExecuteCommandReason)
Raises the ExecuteCommand event
Declaration
public Task ExecuteAsync(ExecuteCommandReason reason)
Parameters
Type | Name | Description |
---|---|---|
ExecuteCommandReason | reason |
Returns
Type | Description |
---|---|
Task |
Remarks
Can be used as a programmatic way of simulating e.g. a menu choice
FromID(String)
Returns the CommandBarButton that has the specified ID, or null if none exists.
Declaration
public static CommandBarButton FromID(string id)
Parameters
Type | Name | Description |
---|---|---|
String | id | ID to find button for |
Returns
Type | Description |
---|---|
CommandBarButton | The CommandBarButton with the specified ID |
Remarks
This is the same as UIEnvironment.CommandBarControls[id] as CommandBarButton
FromKeyboardShortcut(Keys)
Returns the CommandBarButton that is bound to the given shortcut key, or null if the key is not used.
Declaration
public static CommandBarButton FromKeyboardShortcut(Keys key)
Parameters
Type | Name | Description |
---|---|---|
Keys | key | The key to find the button for |
Returns
Type | Description |
---|---|
CommandBarButton |
Events
ExecuteCommand
This event is raised when the user selects the CommandBarButton
Declaration
public event ExecuteCommandEventHandler ExecuteCommand
Event Type
Type | Description |
---|---|
ExecuteCommandEventHandler |
UpdateCommandUI
This event is raised before the button is drawn, to allow its appearance to be modified
Declaration
public event UpdateCommandUIEventHandler UpdateCommandUI
Event Type
Type | Description |
---|---|
UpdateCommandUIEventHandler |