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
TView
orTBehavior
can handle a mouse event by overriding theDoMouseCommand
method. Your application can handle mouse events directly in subclasses ofTView
and 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
DoMouseCommand
method handles a mouse event by creating a mouse-tracking command object and posting it to the command queue. MacApp provides theTTracker
class for responding to user actions with the mouse. TheTTracker
class supplies methods for tracking the cursor, constraining cursor movement, and providing user feedback.In the
TTracker
class, theTrackConstrain
,TrackFeedback
, andTrackMouse
methods just call methods of the same name in the command's view. This allows MacApp's control view classes, such asTButton
andTCheckBox
, to track the mouse within the view object. More commonly, you handle drawing, selecting, or dragging with the mouse by defining a subclass ofTTracker
and overriding theTrackConstrain
,TrackFeedback
, andTrackMouse
methods. To make the command undoable, you override theDoIt
,UndoIt
, andRedoIt
methods or have theTrackMouse
method post an undoable command when it has finished tracking.