- Code: Select all
Hi, ppfer.
I just finished up writing a button toggle/highlight system that might work for you. It uses an integer array to keep track of the selection state of things - in my case, it's projectors, but I think it'd work as well for cues or sequences.
My array (selectedProjectors) is just 1 and 0 values, and there are two functions that act on it -
toggleSelection{}, which takes the ID of the button and toggles whether that value in the array is a 1 or a 0, and
highlight{}, which reads through the array and sets the text colors of the associated buttons - in my case, red indicates selected and boring gray is unselected.
I first initialize the array:
- Code: Select all
VDelete,selectedProjectors
VIntArray,selectedProjectors,0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
That gives me 19 objects, each representing a projector, and all in the unselected (0) state.
Here's toggleSelection{}:
- Code: Select all
VGetArrayValue,j,pj,selectedProjectors
if j = 1
{
VSetArrayValue,selectedProjectors,pj,0
}
else
{
VSetArrayValue,selectedProjectors,pj,1
}
highlight{}
This just checks the value of an item in the array (at the position indicated by the parameter 'pj'). If it's a zero, it changes it to a 1, and vice versa, and then runs the highlight{} function on the array. The 'pj' parameter is passed to the function from the button's code, and is equal to the button's ID.
and highlight{}:
- Code: Select all
i=1
for 1 to 19
VGetArrayValue,j,i,selectedProjectors
if j = 1
{
WDCustomScriptTextColour,i,255,0,0
}
else
{
WDCustomScriptTextColour,i,128,128,128
}
i+=1
next
Where this setup saves time is that the code for each button is the same:
- Code: Select all
toggleSelection{myID}
Two caveats - the buttonIDs need to match their respective object's position in the array (I didn't think of this soon enough, and have so they're all numbered 100 higher, and there's code to add/subtract 100 from everything. Messy and annoying.), and this allows for the selection of multiple things - desirable in my application, but probably less so when it comes to playing cues or sequences. Maybe instead of an array, just run highlight{MyID} in each of your buttons?