14. Interactively resizing an image

In the above section, we have explained how to bind a keystroke: Shift+ENTER to a command: sect.insertBreak. Similarly, interactively resizing an image may be implemented by binding an application event: resize-image to a command: resizeImage.

<binding>
  <appEvent name="resize-image" />
  <command name="resizeImage" 
           parameter="height=%{height} width=%{width}" />
</binding>

Resize-image events are emitted when the user first clicks inside an image in order to display handles around it and then drag one of those handles.

Figure 2.3. Resize handles around an image

Resize handles around an image

In the case of the "Simple Section" configuration, dragging a resize handle invokes command resizeImage in XMLmind XML Editor - Commands. This command resizes an image by modifying its width and height attributes.

It's important to understand that the resize image command being invoked must correspond to the image element. If the image element had no width and height attributes or if these attributes contained inches rather than pixels, built-in command resizeImage would not be usable here.

For example, it's possible to interactively resize a column of a table by binding application event resize-table-column to the proper command. However the table element of the "Simple Section" document type has no child element or attribute allowing to specify the width of a column. Therefore, in the case of the "Simple Section" configuration, there is no way to specify how a user can resize a table column by dragging the corresponding column separator.