Slider & Field Example
Now we will look at a simple broadcasting example. Broadcasting is a way for controls to "sign-up" to receive messages when certain events occurs. In this example we will notify a field that the slider position of a scrollbar has changed.
Open the BMLSBroadcastHelper Plugin
This plugin is distributed with the GLX Application Framework in the extra resources/plugins folder.
When you select the Scrollbar the plugin updates to show any messages that the control is broadcasting (1), who is listening to those broadcasts (2) and any broadcasts the control is listening for (3).
Click on the Add a published broadcast to selected control button (4).
Enter Broadcast Type
Enter value changed as the broadcast type.
Enter Default Broadcast Message
Enter SliderValueChanged as the message that will be broadcast when the value changes.
You will now see an entry under What Broadcasts Am I Sending?.
Have Field Listen For Broadcast
Now that you have defined a broadcast you can have other controls listen for it. Click on the value changed row (1) and drag and drop onto the field (2).
Now the field will be listed under Who's Listening To Me?.
If you select the field (1) the plugin updates to show that the field is listening for a broadcast from the slider (2).
Update Slider Script
So far we have only published the fact that the slider will broadcast a message and that the field wants to hear about it. We still have to add the code that actually broadcasts the message when the scrollbar slider value changes.
Add this scrollbarDrag handler to the end of the script in the scrollbar. Doing so will send messages to any controls that have registered to listen for the value changed broadcast.
on scrollbarDrag pScrollValue
glxapp_broadcast the long id of me, "value changed", pScrollValue
Edit Field Script
Now the field needs to process the message that is sent to it so we will add some RevTalk code that does that.
Set Field Script
Set the script of the field to the following RevTalk code. This code processes the SliderValueChanged message and sets the text of the field to the new scrollbar value.
on SliderValueChanged pNewValue
set the text of me to pNewValue
Drag the slider. The field should update.
Although this is a simple example, hopefully it gives you an idea of how broadcasting works. Broadcasting allows an event to be published (such as the changing of a scrollbar slider) without concern for who is interested in the message. Any other control can sign up to be notified without adding additional code to the control (or library command) sending out the broadcasting.