Important: The information in this document is obsolete and should not be used for new development.
Chapter 13 -
This chapter provides recipes and sample code that demonstrate how to
Working With Events and Commands
For an overview of event handling in MacApp, see Chapter 1, "MacApp Overview."
- create a command object to perform an action (a general outline)
- implement an undoable Zoom In menu command
- change the current target object and perform validation
- ensure idle time for an event-handler object when it's not in the target chain
- use a behavior object to implement alphabetic type-ahead
For a detailed description of event dispatching and the use of command objects to respond to events, see Chapter 5, "Events and Commands."
For a description of Apple event dispatching, see Chapter 6, "Scripting."
For information on working with Apple events, see Chapter 14, "Working With Scripting."
Chapter Contents
- Overview
- Which Object Should Handle an Event or Menu Command
- Working With Behaviors
- Recipes--Events and Commands
- Creating a Command Object to Perform an Action--A General Overview
- Recipe--Implementing an Undoable Zoom In Menu Command
- Define a Command-Number Constant for the Zoom In Menu Item
- Add the Zoom In Menu Item to a 'CMNU' Resource
- Implement a Command Class That Handles Zoom In
- The IZoomInCommand Method
- The DoIt Method
- The RedoIt Method
- The UndoIt Method
- Override DoSetupMenus in the View Class
- Override DoMenuCommand in the Document Class
- Recipe--Changing the Current Target Object and Performing Validation
- Changing the Current Target Object
- Performing Validation When a Target Change Is Attempted
- Recipe--Ensuring Idle Time for an Event-Handler Object
- Override the DoIdle Method
- Install the Object in the Cohandler Chain
- Set the fIdleFreq Field to Specify How Often DoIdle Should Be Called
- Remove the Object From the Cohandler Chain
- Recipe--Using a Behavior Object to Implement Alphabetic Type-Ahead
- Define a View Class That Descends From TTextListView
- Add a TKeySelectionBehavior Behavior to the View Object