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

NameTypegetsetDescripton
checkedBooleancheckedcheckedThe 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).
enabledBooleancheckedcheckedWhether the command is enabled.
keyCodeNumbercheckedcheckedThis 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.
ownerWindowBiWindow / BiApplicationWindowcheckedIf 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.
shortcutStringcheckedcheckedThe 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
shortcutBubblesBooleancheckedcheckedWhether the keyboard shortcut is available to child windows or only the owner window.
userValueObjectcheckedcheckedThe 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

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

Events

NameTypeBubblesDescripton
checkedchangedBiEventThis is fired when the checked property is changed.
enabledchangedBiEventThis is fired when the enabled property is changed.
executeBiEventThis is fired when the command is executed.
shortcutchangedBiEventThis is fired when the shortcut property is changed.
uservaluechangedBiEventThis 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 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

NameTypeOptionalDefaultDescripton
eBiKeyboardEventThe keyboard event object used in the keypress event.

Return Type

Boolean