BiCommand

Command objects can be used to make several user interface components execute the command when they are invoked. Components that use the command object will be synchronized with the properties of the command. For example, if a button has a disabled command the button will also be disabled.

This class extends BiEventTarget and therefore all methods and fields available for BiEventTarget are also available for BiCommand .

Constructor

new BiCommand ( )

Parameters

No parameters.

Properties

Name Type get set Descripton
checked Boolean checked checked The checked state of the command. This is usually used to synchronize the checked property of the components using this command (such as BiRadioButton, BiCheckBox and others).
enabled Boolean checked checked Whether the command is enabled or not
keyCode Number checked checked This gives a bit more detail than the shortcut property because there are cases where there is no name for the key. Use shortcut whenever possible and fall back on keyCode when needed. If keyCode is provided only the modifiers from the shortcut is used.
ownerWindow BiApplicationWindow / BiWindow checked If the command has an owner window and a shortcut or a keyCode the command will be executed when the user presses the keys needed to execute the command. To set the owner window call addCommand on the window. By the default the owner window is set to the application window upon creation.
shortcut String checked checked The keyboard shortcut used to execute the command. The format for the shortcut is:

Ctrl+Shift+Alt+k

You can also use the static fields of BiKeyboardEvent for describing the key codes:

Shift+Del
userValue Object checked checked The user value of the command. This is usually used to synchronize the user values of the components using this command (such as BiRadioGroup and BiComboBox).

Methods

Name Description
execute Executes the command. This returns false if any event listener, listening to the execute event, prevented the default action by calling event preventDefault.
matchesKeyboardEvent This method is called by the ownerWindow when a keypress event occurs. If the keys pressed match the shortcut property this returns true.

Events

Name Type Bubbles Descripton
checkedchanged BiEvent This is fired when the checked property is changed.
enabledchanged BiEvent This is fired when the enabled property is changed.
execute BiEvent This is fired when the command is executed.
shortcutchanged BiEvent This is fired when the shortcut property is changed.
uservaluechanged BiEvent This is fired when the userValue property is changed.

Static Methods

None.

Static Fields

None.

Remarks

For the shortcut to work inside an internal window you need to add the command to the window using addCommand.

Method Details

execute

Executes the command. This returns false if any event listener, listening to the execute event, prevented the default action by calling event preventDefault.

Syntax

object.execute
 (
 
 )
 

Parameters

No arguments.

Return Type

Boolean

matchesKeyboardEvent

This method is called by the ownerWindow when a keypress event occurs. If the keys pressed match the shortcut property this returns true.

Syntax

object.matchesKeyboardEvent
 (
 e
 )
 

Parameters

Name Type Optional Default Descripton
e BiKeyboardEvent

Return Type

Boolean