VisClass: 5.3 Working with Visible Object Trees: Getting Visible Tree Information

Up: GEOS SDK TechDocs | Up | Prev: 5.2 Adding and Removing | Next: 5.4 Sending Messages Through the Tree
 MSG_VIS_FIND_CHILD, MSG_VIS_FIND_CHILD_AT_POSITION, MSG_VIS_COUNT_CHILDREN, MSG_VIS_FIND_PARENT

When an application manages a visible object tree, it will most likely need to find children, count children, or get the optr of a particular object in the tree. VisClass offers four messages to provide this bookkeeping information. These four messages are listed below.

MSG_VIS_FIND_CHILD

word	MSG_VIS_FIND_CHILD(
        optr	object);

This message returns the zero-based position of the specified child among the parent's children.

Source: Unrestricted.

Destination: Any visible composite object.

Parameters: object The optr of the child to be found.

Return: The zero-based position of the child in the parent's child list. (E.g., the first child returns zero, the second child returns one, the third child returns two, etc.) If object is not the optr of one of the composite's children, the value -1 will be returned. If sent to a non-composite object, the message will also return -1.

Interception: Unlikely.

MSG_VIS_FIND_CHILD_AT_POSITION

optr	MSG_VIS_FIND_CHILD_AT_POSITION(
        word	position);

This message returns the optr of the child occupying the position specified among the recipient's children.

Source: Unrestricted.

Destination: Any visible composite object.

Parameters: position The zero-based position of the child whose optr is to be returned.

Return: The optr of the child occupying the passed position . If no child occupies that position, or if the message is sent to a non-composite object, the retuned value will be NullOptr.

Interception: Unlikely.

MSG_VIS_COUNT_CHILDREN

word	MSG_VIS_COUNT_CHILDREN();

This message returns the number of children the recipient object has. The count is not zero-based; if a composite has five children, this message will return five.

Source: Unrestricted.

Destination: Any visible composite object.

Parameters: None.

Return: The number of children the object has. If the object has no children (includes non-composite objects), the return will be zero.

Interception: Unlikely.

MSG_VIS_FIND_PARENT

optr	MSG_VIS_FIND_PARENT();

This message returns the optr of the recipient's parent composite.

Source: Unrestricted.

Destination: Any visible composite object.

Parameters: None.

Return: The optr of the object's parent composite. If the message is sent to the top node of a visible tree, the return value will be NullOptr.

Interception: Unlikely.

Tips: If you want to send a message to your parent, use the @visParent macro defined in the next section.


Up: GEOS SDK TechDocs | Up | Prev: 5.2 Adding and Removing | Next: 5.4 Sending Messages Through the Tree