10. Interactivity

10.1 Basics

Triggers and actions provide interactivity to X2D documents. Triggers act as conditionals, which when satisfied, set off a given set of actions.

10.2 Interaction controllers: the <controller> tag

To add interactivity to a component, an interaction <controller> needs to be specified within a component definition. Any component can have a <controller>. Each controller can contain an arbitrary amount of <trigger> tags (see  next section).

10.3 Event triggers: the <trigger> tag

The <trigger> tag allows the X2D file to specify event triggers which can activate given <action> commands.

For each event type, the condition attribute specifies the specific condition which triggers the event. These conditions can be ANDed together to form a more complex condition, such as "OnOver && OnUp" which will trigger an action whenever the mouse button goes up over the target component.

The type attribute specifies which activities are being monitored to satisfy the condition. There are currently three types: mouse, pointer, and gesture. Soon, frame activity will also be monitored. That is, when a given frame is loaded in an animation/movie, the given action(s) will be triggered.

The following example illustrates the use of <controller> and <trigger> tags.

<x2d width="4" height="3">
  <rectangle dim="100 100">
    <controller>
      <trigger type="pointer" condition="OnIn">
        <reconfigure target="rect2" size="500 500"/>
      </trigger>
      <trigger type="pointer" condition="OnOut">
        <reconfigure target="rect2"color="1 0 0 1"/>
      </trigger>
      <trigger type="pointer" condition="OnIn">
        <reconfigure target="actionspot1" active="true"/>
      </trigger>
    </controller>
  </rectangle>
</x2d>

10.4 Type specific conditions

This section lists the various types of conditions that are monitored for each input/activity type.

10.4.1 Mouse events

The conditions for the mouse events are:

A mouse event would look as follows:

  <trigger type="mouse" condition="OnDown"/>

10.4.2 Pointer events

Pointer events are similar to mouse events, except that pointers lack pushbuttons.

A pointer event would look as follows:

  <trigger type="pointer" condition="OnIn"/>

10.4.3 Gesture events

A condition can also take the form of a Unistrokes gesture, in which case the condition attribute takes the value of the gesture. For example:

  <trigger type="unistrokes" condition="UC_I7"/>

Currently Unistroke gestures are encoded in a cryptic manner. This will be fixed to provide a more descriptive representation.

10.4.4 Animation events

Animation ticking can also cause actions. That is, when a specific frame is played, then a corresponding action is triggered.

  <trigger source="Animation1" type="animation" frame="5"/>

Note: Where should this be specified? Within controller tag where the rest of the trigger specifications are? Or within an animation definition where it is more intuitive where the animation activity is coming from? I don't know. Need to work this out.