|
Fancy Checkboxes
This tutorial won't go step by step but
instead will show you how state filtering works starting from an existing demo.

-
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 disappearing on mouse away).
-
We got this button working by
basically creating a custom Mouse over / Mouse away behavior.
-
This is the full script used into the
outline object:

Script example with color-coding in editor.
(The following script can be copied &
pasted.)
Dim toggled
Sub Object_OnScriptEnter
toggled = False
End Sub
Sub Object_OnLButtonUp(x,y,bDragged)
If bDragged = False Then
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).
|