Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am
by Craig Shearer >> Wed, 14 Jun 2000 22:26:18 GMT
I usually use the eventTag parameter with all my notification subscriptions, just out of habit. It usually turns out to be more convenient anyway, otherwise you are left to test both the eventType and theObject parameters to uniquely identify the particular notification received in the case where you have subscribed to multiple notifications.
However, it is most useful when receiving notifications from different objects each of which will be processed in the same way.
For example, you might have a Tree View control containing hetrogeneous items, and register notifications on each of the classes. For each class's delete notification, you might register the same eventTag, meaning that for any deletions of objects, they will be handled in the same manner.
You might also find it useful when handling deleted object notifications. If you receive a notification for a deleted object, then you CAN'T do the following:
if theObject.isKindOf(SomeClass) then
// handle deletion of a SomeClass object...
as theObject has been deleted, you can't call a method on it! Therefore, in these situations, the eventTag parameter can identify the type of object.
John's Timer example is also good. You might have several timers with differing periods, but you only have one timerEvent method. Therefore, the eventTag parameter is essential to identify which timer has fired.
HTH
Craig.