Private Sub p_Touch (Action As Int, X As Float, Y As Float) As Boolean
If mDisabled Then Return True
Dim Inside As Boolean = x > 0 And x < mBase.Width And y > 0 And y < mBase.Height
Select Action
Case mBase.TOUCH_ACTION_DOWN
SetPressedState(True)
Draw
TouchEventStarted = DateTime.Now 'Capture the time that the user started touching the panel.
Case mBase.TOUCH_ACTION_MOVE
If pressed <> Inside Then
SetPressedState(Inside)
Draw
End If
Case mBase.TOUCH_ACTION_UP
SetPressedState(False)
Draw
If Inside Then
TouchEventDuration = DateTime.Now - TouchEventStarted 'Calculate touch duration
If TouchEventDuration <= TouchEventMaxDuration Then 'Click event
CallSubDelayed(mCallBack, mEventName & "_Click")
Else ' longClick / Touch event raised as LongClick
CallSubDelayed(mCallBack, mEventName & "_LongClick")
End If
End If
End Select
Return True
End Sub