The Trigml extension that implements an element will typically attach an object to the element in its ITRIGMLEXTENSION_ElementCreated() notification. The object can then be retrieved and manipulated in subsequent ITRIGMLEXTENSION_*() notifications by calling ITRIGMLELEMENT_GetAttachedObject().
The element will AddRef the object. It will be Released either when a new object is attached or when the element itself is destroyed. At most one object can be attached to each Trigml element.
- po:The element to which to attach the object.
- obj:The object to attach. Supply NULL to Release a previously-attached object without attaching a new one.
void ITRIGMLELEMENT_AttachObject(ITrigmlElement* po, IQueryInterface* obj);
There are two important special cases for attached objects.
1. If you declare an element as having type 'visible' in the extension's XML metadata (normally you do this by adding it to the 'visibleContainer' or 'visibleLeaf' element classes), and the object you attach implements IWidget, then your element will then inherit all default layout and widget tree behavior from the core Trigml extension.
2. If you declare an element as having type 'listener' in the extension's XML metadata (normally you do this by adding it to the 'listeners' or 'modifiers' element classes), then the object you attach should implement ITrigmlListenerAction. Your element will then inherit the when, while, until and consume attributes that are common to Trigml listeners and modifiers. Your extension will be notified when your listener is activated or deactivated via calls to ITRIGMLLISTENERACTION_Activate().