Moving tiles

In this step the Tiles program adds the ability for the user to select a tile and move it around the view by clicking on the tile and dragging it with the mouse.


To provide this behavior, the Tiles program requires a command, TMoveCommand, that modifies the position of a selected tile and a mouse interactor, TMoveInteractor, that tracks the mouse movement and incrementally applies the command as the mouse is dragged. Note that TMoveCommand is not dependent on this interactor. You could create another interactor that allows a user to move the tile in some other way, for example, using the arrow keys on the keyboard.

When the user selects a tile, the view's MouseDown function starts a TMoveInteractor. If the user keeps the mouse down and drags the tile, the interactor:

  1. Creates a TMoveCommand.
  2. Gets the current selection from the view.
  3. Binds the command to the selection.
  4. Incrementally executes the command as long as the user continues dragging the mouse within the view. The command finishes executing when the user releases the mouse button.
This figure shows how the interactor works with the document component:



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker