1. action
Prev | Chapter 4. Reference | Next

## 1. action

    <action
      name = NMTOKEN
      label = non empty token
      icon = anyURI
      selectedIcon = anyURI
      toolTip = non empty token
      accelerator = non empty token
      acceleratorOnMac = token
    >
      Content: class | command
    </action>

    <class
      implementsCommand = NMTOKEN
    >
      Content: Java class name
    </class>

    <command
      name = NMTOKEN
      parameter = string
      selectedParameter = string
      selectedValue = string : "true"
      editingContextSensitive = boolean : true
    />

Specifies an action, that is, an instance of class `com.xmlmind.xmleditapp.kit.AppAction`.

The class derived from `com.xmlmind.xmleditapp.kit.AppAction` is specified by the `class` child element. In a few cases, this class also implements interface `com.xmlmind.xmledit.gadget.Command`. In such case, attribute `implementsCommand` specifies the name of the command.

The `action` element also allows to specify different kinds of AppActions without having to write Java™ code for that:

Child element `command`

  Specifies an action which delegates its job to a command (see Chapter 6, Commands written in the Java™ programming language in XMLmind XML Editor - Commands). See example in the tutorial part of this document. Explanations below.

Attributes:

`name`

  Required. Unique name identifying the action in this GUI specification.

`label`

  One of `label` and `icon` is required. Label of the action (an action is used to create buttons, menu items and tool bar items).

`icon`

  One of `label` and `icon` is required. Icon of the action (an action is used to create buttons, menu items and tool bar items).

  This URI may be resolved using XML catalogs.

`selectedIcon`

  Only used for an action which acts as a toggle. The icon specified by attribute `selectedIcon` is used when the toggle is turned on. The icon specified by attribute `icon` is used when the toggle is turned off.

  Class `com.xmlmind.xmleditapp.kit.ToggleOptionAction` may be used implement an action which acts as a toggle. See example below. This is also the case when the `command` child element has a `selectedParameter` attribute. See Section 1.1, “Action which is a wrapper around a command”.

  This URI may be resolved using XML catalogs.

`toolTip`

  The tool tip of the action (an action is used to create buttons, menu items and tool bar items).

  If this attribute is not specified, and if a tool tip is absolutely needed by the representation of the action (button, menu item and tool bar item), the value of attribute `label` will be used.

`accelerator`

  The hot key used to trigger the action.

  Hot keys are specified using the following syntax:

      [ ctrl|shift|alt|meta|mod ]* key_code

      key_code = (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
                  9 | A | ACCEPT | ADD | AGAIN |
                  ALL_CANDIDATES | ALPHANUMERIC | AMPERSAND |
                  ASTERISK | AT | B | BACK_QUOTE | BACK_SLASH |
                  BACK_SPACE | BRACELEFT | BRACERIGHT | C |
                  CANCEL | CAPS_LOCK | CIRCUMFLEX | CLEAR |
                  CLOSE_BRACKET | CODE_INPUT | COLON | COMMA |
                  COMPOSE | CONVERT | COPY | CUT | D | DEAD_ABOVEDOT |
                  DEAD_ABOVERING | DEAD_ACUTE | DEAD_BREVE |
                  DEAD_CARON | DEAD_CEDILLA | DEAD_CIRCUMFLEX |
                  DEAD_DIAERESIS | DEAD_DOUBLEACUTE | DEAD_GRAVE |
                  DEAD_IOTA | DEAD_MACRON | DEAD_OGONEK |
                  DEAD_SEMIVOICED_SOUND | DEAD_TILDE |
                  DEAD_VOICED_SOUND | DECIMAL | DELETE |
                  DIVIDE | DOLLAR | DOWN | E | END | ENTER |
                  EQUALS | ESCAPE | EURO_SIGN | EXCLAMATION_MARK |
                  F | F1 | F10 | F11 | F12 | F13 | F14 | F15 | F16 | F17 |
                  F18 | F19 | F2 | F20 | F21 | F22 | F23 | F24 | F3 | F4 |
                  F5 | F6 | F7 | F8 | F9 | FINAL | FIND | FULL_WIDTH |
                  G | GREATER | H | HALF_WIDTH | HELP | HIRAGANA |
                  HOME | I | INPUT_METHOD_ON_OFF | INSERT |
                  INVERTED_EXCLAMATION_MARK | J | JAPANESE_HIRAGANA |
                  JAPANESE_KATAKANA | JAPANESE_ROMAN | K | KANA |
                  KANA_LOCK | KANJI | KATAKANA | KP_DOWN | KP_LEFT |
                  KP_RIGHT | KP_UP | L | LEFT | LEFT_PARENTHESIS |
                  LESS | M | MINUS | MODECHANGE | MULTIPLY | N |
                  NONCONVERT | NUMBER_SIGN | NUMPAD0 | NUMPAD1 |
                  NUMPAD2 | NUMPAD3 | NUMPAD4 | NUMPAD5 | NUMPAD6 |
                  NUMPAD7 | NUMPAD8 | NUMPAD9 | NUM_LOCK | O |
                  OPEN_BRACKET | P | PAGE_DOWN | PAGE_UP | PASTE |
                  PAUSE | PERIOD | PLUS | PREVIOUS_CANDIDATE |
                  PRINTSCREEN | PROPS | Q | QUOTE | QUOTEDBL | R |
                  RIGHT | RIGHT_PARENTHESIS | ROMAN_CHARACTERS |
                  S | SCROLL_LOCK | SEMICOLON | SEPARATOR | SLASH |
                  SPACE | STOP | SUBTRACT | T | TAB | U | UNDERSCORE |
                  UNDO | UP | V | W | X | Y | Z)

  Note that `mod` is the Command key on Mac and the Control key on other platforms.

  ### Important

  Such hot key cannot override a binding (factory binding or a binding defined in `customize.xxe` — see Chapter 4, Customizing mouse and key bindings used by XXE in XMLmind XML Editor - Configuration and Deployment).

`acceleratorOnMac`

  The hot key used to trigger the action on the Mac. This is needed because on the Mac, so many hot keys are reserved for the desktop.

  If this attribute is not specified, and if attribute `accelerator` is specified, the hot key specified by `accelerator` will also be used on Macs.

  If this attribute is specified as the empty string, the hot key normally specified by `accelerator` is suppressed on the Mac.

Example: a simple action:

    <action name="addViewAction" label="_Add...">
      <class>com.xmlmind.xmleditapp.app.part.AddViewAction</class>
    </action>

Example: an action which implements a command:

    <action name="openAction" label="_Open..."
            icon="icons/openAction.gif"
            accelerator="mod O">
      <class
        implementsCommand="XXE.open"
      >com.xmlmind.xmleditapp.kit.part.OpenAction</class>
    </action>

Example: a action which acts as a toggle:

    <action name="toggleUseURLChooserAction" label="_Use the URL Chooser">
            icon="icons/toggleUseURLChooserAction.png"
            selectedIcon="icons/toggleUseURLChooserAction_selected.png"
      <class>com.xmlmind.xmleditapp.kit.ToggleOptionAction</class>
      <property name="option" type="String" value="useURLChooser" />
      <property name="defaultValue" type="boolean" value="false" />
    </action>

Prev | Up | Next
Chapter 4. Reference | Home | 1.1. Action which is a wrapper around a command