1. XML application specific bindings
Prev | Chapter 3. Customizing mouse and key bindings used by XXE | Next

## 1. XML application specific bindings

A configuration file such as `docbook.xxe` can contain binding elements. A binding element specifies:

- a keystroke or a sequence of keystrokes which triggers a command,

- OR a mouse input which triggers a command or displays a custom popup menu.

For example, adding the following binding element to `docbook.xxe` will allow to convert selected text to emphasis (with role attribute set to bold) by pressing on function key F5:

    <binding>
      <keyPressed code="F5" />
      <command name="docb.convertToBold" />
    </binding>

    <command name="docb.convertToBold">
      <macro>
        <sequence>
          <command name="convert" parameter="[implicitElement] emphasis" />
          <command name="putAttribute" parameter="role bold" />
        </sequence>
      </macro>
    </command>

It is recommended to add custom bindings into a separate file and to include this file in configurations files bundled with XXE rather than directly modifying the bundled configuration files.

For example, if you want to use the F5 key for converting text to emphasis in all documents belonging to the DocBook family (DocBook, Simplified DocBook, Slides), add the elements of the previous example to a file called `/opt/xxe-custom/extrabindings.incl` and include this file in ``XXE_install_dir`/addon/config/docbook/common.incl`.

    <include location="file:///opt/xxe-custom/extrabindings.incl" />

In next chapter, we will learn how to customize an existing configuration as a whole. We will use the DocBook configuration as an example.

### Important

XXE does not allow bindings defined in XML application specific configuration files to override its menu accelerators.

Example 1: you cannot bind Ctrl-Q to command `docb.convertToBold` because Ctrl-Q is used to quit XXE.

Example 2: you cannot bind Ctrl-I to command `docb.convertToBold` because, by default, Ctrl-I triggers command "`insert`" with parameter "`into`" (menu item Edit|Insert).

Prev | Up | Next
Chapter 3. Customizing mouse and key bindings used by XXE | Home | 2. Generic bindings