Important: The information in this document is obsolete and should not be used for new development.
Overview
Whenever a user presses or releases the mouse button, MacApp receives a Toolbox event describing the action. In some cases, MacApp handles the event for you; in others, it passes the event on to your code. For example, MacApp takes care of a click in the Apple menu, but your application handles the event when a user clicks in the content area of your window.Any class that descends from
TVieworTBehaviorcan handle a mouse event by overriding theDoMouseCommandmethod. Your application can handle mouse events directly in subclasses ofTViewand through attached behavior objects in subclasses ofTEventHandler, includingTApplication,TDocument, andTWindow. Mouse events are most commonly handled by objects of the view class.A view object's
DoMouseCommandmethod handles a mouse event by creating a mouse-tracking command object and posting it to the command queue. MacApp provides theTTrackerclass for responding to user actions with the mouse. TheTTrackerclass supplies methods for tracking the cursor, constraining cursor movement, and providing user feedback.In the
TTrackerclass, theTrackConstrain,TrackFeedback, andTrackMousemethods just call methods of the same name in the command's view. This allows MacApp's control view classes, such asTButtonandTCheckBox, to track the mouse within the view object. More commonly, you handle drawing, selecting, or dragging with the mouse by defining a subclass ofTTrackerand overriding theTrackConstrain,TrackFeedback, andTrackMousemethods. To make the command undoable, you override theDoIt,UndoIt, andRedoItmethods or have theTrackMousemethod post an undoable command when it has finished tracking.