DrawKit
Vector and illustration framework for Mac OS X
Instance Methods | List of all members
NSObject(DKToolDelegate) Category Reference

The drawing tool protocol must be implemented by all tools that can be used to operate on a drawing. More...

Instance Methods

(void) - toolDidPerformUndoableAction:
 
(void) - toolWillPerformUndoableAction:
 

Detailed Description

The drawing tool protocol must be implemented by all tools that can be used to operate on a drawing.

The drawing tool protocol must be implemented by all tools that can be used to operate on a drawing. Getting tools right is tricky, because of all the different cases that need to be considered, undo tasks, and so forth. Thus the following rules must be followed:

  1. On mouseDown, a tool needs to decide what it is going to do, and return the partcode of the hit part for the object under consideration. At this point however, it should NOT perform the actual action of the tool.
  2. The partcode returned in 1, if non-zero, will be passed back during a mouse drag.
  3. On mouse UP, the tool must carry out its actual action, returning YES if the action was carried out, NO if not. The correct return values from mouse down and mouse up are essential to allow the correct management of undo tasks that arise during the tool's operation.
  4. Tools that do not affect the data content of a drawing (e.g. a zoom tool, which affects only the view) should return 0 and NO respectively.
  5. Tools that perform an action that can be considered undoable must implement +toolPerformsUndoableAction returning YES and also supply an action name when requested.
  6. Tools must supply a cursor which is displayed during the mouse down/drag/up sequence and whenever the tool is set.

Method Documentation

- (void) toolDidPerformUndoableAction: (id< DKDrawingTool >)  aTool
- (void) toolWillPerformUndoableAction: (id< DKDrawingTool >)  aTool