Next: Implementation notes Up: Interaction mechanisms Previous: Bindings

## Interactors

The second interaction mechanism is based on interactors, proposed by Myers in 1990 [8] and implemented in the Garnet toolkit and its successor, Amulet [8, 9]. Interactors abstract user interaction from the lower-level events upon which they are built, and in the process modularize the code and make it more re-usable.

An interactor is an object that intercepts events and translates them into operations on a target item. For example, a Follower interactor - so called because it ``follows'' the mouse - translates mouse events into calls to the moveclick, movedrag, and moverelease methods of the slate. To create a Follower interactor, we can execute, say:

      set follower [$slate interactor Follower]

To make an interactor operate on an item, we bind the interactor to that item. For example,

      $follower bind $frame -button 1

Now, dragging the frame item with the mouse makes it move - simple! To stop the item from responding to the mouse, unbind the interactor:

      $follower unbind $frame -button 1

The right side of figure 6 illustrates two interactors bound to nodes of a hierarchy. Interactors can be cascaded to create more complex interaction. For example, an interactor that moves an object only within a certain region of the slate can be cascaded with an interactor that quantizes movement to ten-pixel steps.

A more complex combination is achieved with the Selector interactor, which manages a graphical selection in the same manner as typical drawing programs. When items become selected, the Selector delegates interaction events to another interactor according to various conditions that can be set up by the programmer. For example, it might forward mouse and keyboard events to a LineEditor interactor if there is only a single text item selected, and forward mouse events to a Follower interactor if more than one item is selected.

Interactors allow user interaction code to be modularized, and, just as importantly, reused. In addition, they allow highly dynamic user interaction, such as changing the effect of the mouse depending on the context (such as the number of items selected). This kind of dynamic modification of user interaction would be very difficult if coded directly using event bindings. Some additional examples of interactors are given in section 5.

Figure 7: The interactor classes

Next: Implementation notes Up: Interaction mechanisms Previous: Bindings