This tutorial won't go step by step but instead will show
you how state filtering works starting from an existing demo.
Download the demo
here and import it as objects inside your theme.
You'll see three buttons. Try to mouse over them and
click on them. You'll see they behave like check-boxes. They have a selected
state (green outline) and a fading in-out unselected state (yellow outline
dissapearing on mouse away).
We got this button working by basically creating a
custom Mouse over / Mouse away behaviour.
This is the full script used into the outline object:
Dim
toggled
Sub Object_OnScriptEnter toggled
= False
End Sub
Sub Object_OnLButtonUp(x,y,bDragged) If bDragged =
FalseThen
If toggled =
False Then Object.State
= "Selected" toggled=True ElseIf toggled
= True Then Object.State
= "Unselected" toggled=False
End If End If End Sub
Sub Object_OnStateChange(newstate) If toggled =
False Then If newstate =
"Mouse away"
Then Object.StatePreempt
= "Unselected mouse away" ElseIf newstate
= "Mouse over"
Then Object.StatePreempt
= "Unselected mouse over"
End If End If End Sub
The script holds a boolean with the actual status information (selected
/ unselected).
The Object_OnStateChange code
receives "Mouse away" and "Mouse over" event notifications even if such
states don't exist. The code redirects the state change to the actual custom
states (yellow outline in-out fading, only in unselected state).