You can also create your own predefined action classes. When you write your own action classes, you can build in the ability to execute on certain target classes of objects. Then, you can use your custom actions in the same way you use predefined action classes. That is, when the action can recognize and apply itself to a target class, you can simply assign the action to a client control, and it acts on the target with no need to write an event handler.
Component writers can use the classes in the QStdActns and DBActns units as examples for deriving their own action classes to implement behaviors specific to certain controls or components. The base classes for these specialized actions (TEditAction, TWindowAction, and so on) generally override HandlesTarget, UpdateTarget, and other methods to limit the target for the action to a specific class of objects. The descendant classes typically override ExecuteTarget to perform a specialized task. These methods are described here:
Methods overriden by base classes of specific actions
Method |
Description |
HandlesTarget |
Called automatically when the user invokes an object (such as a tool button or menu item) that is linked to the action. The HandlesTarget method lets the action object indicate whether it is appropriate to execute at this time with the object specified by the Target parameter as a "target". See How actions find their targets for details. |
UpdateTarget |
Called automatically when the application is idle so that actions can update themselves according to current conditions. Use in place of OnUpdateAction. See Updating actions for details. |
ExecuteTarget |
Called automatically when the action fires in response to a user action in place of OnExecute (for example, when the user selects a menu item or presses a tool button that is linked to this action). See What happens when an action fires for details. |
When you write your own action classes, it is important to understand the following:
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|