Action framework

Sometimes it is useful to pass messages between objects where the sender and receiver have no explicit knowledge of each other, except the kinds of messages that the sender might send to the receiver, and the kind of message distribution that the sender uses. To establish an implicit connection between the sender and receiver, all the receiver has to do is ensure that the distribution mechanism can find the receiver.

For example, a very useful mechanism is one based on a view hierarchy where the sender sends messages up the view hierarchy and the receiver is some parent view. The sender doesn't necessarily know that the parent view is there and the receiver doesn't necessarily know that there is a child view that sends something. This situation can easily arise when composing user interfaces with various parts that were designed independently.

The Action Framework makes this kind of implicit communication possible. Figure 53 shows how a parent view can receive an action message from a child view by mixing in the MViewActionHandler and MActionTarget classes. The sender sends a TViewAction using a TViewActionDistributor. View actions contain a standard text string for the message.


Intermediate views in the view hierarchy do not need to do anything to support actions passing by them. In particular, they do not have to manually pass the action to the parent view. This is automatically done by the view action distributor.

The action receiver also has to declare the dynamic cast declarations macros for its inherited view class, and for the MViewActionHandler and MActionTarget mixins.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker