Broadcast_Focus
See Also: Broadcast, Delegate, Forward, Get, Send, Set
Purpose
To send a message to child focus objects of an object.
Syntax
Broadcast_Focus [Recursive | Recursive_Up] [No_Stop] {Get | Set | Send} {messageā¦}
Where {messageā¦} is the name and syntax of the message to broadcast. Refer to the Get, Set, or Send commands for more information on their respective syntax.
What It Does
The Broadcast_Focus command sends a message to the focus children of an object. Focus children are those objects that are at the next level of the focus tree. These objects receive the message in the order in which they appear in the focus tree.
The primary difference between the Broadcast and Broadcast_Focus commands is that the Broadcast command uses the object tree for its navigation from node to node, whereas Broadcast_Focus uses the focus tree.
The Recursive option allows a message to be sent to all generations descended from an object in the focus tree, instead of just its immediate focus children. The message will be sent to an object's focus child and then to all of the objects in the next level of the focus tree of the focus child. It will continue to descend down to the bottom of the tree before proceeding to the next focus child. This option allows the message to be sent to the focus parent before it is sent to its focus children. This is useful when the parent of an object must be notified of an event before its children are.
If the Recursive_Up option is used, the recursion will proceed to the lowest level that it will go, then send the message to all objects on the way out of the function. This method of recursion will allow the lowest levels to be affected before the parent. It may be used to deactivate children, destroy children, set values of properties, etc.
If a recipient object is not specified in the Get, Set, or Send, all activated objects will receive the message.
When Broadcast_Focus is used with the Get command, broadcasting will terminate when the first non-zero integer value is returned from an object in the focus tree of the object.
The Broadcast_Focus command will stop when the broadcasted message returns a value not equal to zero. With the No_Stop option, a Broadcast_Focus Get|Set|Send instruction will continue broadcasting when the message returns a non-zero value. Since only functions should return values, this is primarily true for a Broadcast_Focus Get usage. However, there are procedures in DataFlex (runtime and packages) that do return a value. So, the No_Stop option can be useful when calling functions and procedures. When the Broadcast_Focus finishes, the return value will be that of the last object that processed the message.
Notes
-
Prior to the command sending the message, the
Delegation_Modeof each focus child is temporarily changed toNo_Delegate_Or_Errorfor receipt of aBroadcastmessage. This is necessary so that if the child does not understand the message, it will not be delegated back to the parent, possibly causing an endless loop. After the message returns, theDelegation_Modeis restored to its prior value. -
The broadcaster class provides a similar feature for objects that are not related by either the object tree or the focus tree.