Libraries.Interface.Events.TouchListener Documentation

The TouchListener class is used to listen for and react to TouchEvents where the user has begun touching or stopped touching the screen, or is moving a finger across the screen. To use a TouchListener in a program, users should make a new class that inherits from it and overrides TouchBegan, TouchFinished, or TouchContinued.

Inherits from: Libraries.Language.Object

Actions Documentation

BeganTouch(Libraries.Interface.Events.TouchEvent event)

This action is used to respond to a TouchEvent where the user's finger has just touched the screen. The event type of the provided TouchEvent should be BEGAN.

Parameters

Example

use Libraries.Interface.TouchEvent
use Libraries.Interface.TouchListener

class MyListener is TouchListener

    integer lastX = 0
    integer lastY = 0

    action BeganTouch(TouchEvent event)
        lastX = event:GetX()
        lastY = event:GetY()
    end

end

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

ContinuedTouch(Libraries.Interface.Events.TouchEvent event)

This action is used to respond to a TouchEvent where the user's finger is pressed against the screen. This action can be triggered by either the user keeping their finger stationary on the screen, or moving it across the screen. The event type of the provided TouchEvent should be either MOVED or STATIONARY.

Parameters

Example

use Libraries.Interface.TouchEvent
use Libraries.Interface.TouchListener

class MyListener is TouchListener

    integer activeID = -1
    integer distanceX = 0
    integer distanceY = 0

    action BeganTouch(TouchEvent event)
        if activeID = -1
            activeID = event:fingerID
            distanceX = 0
            distanceY = 0
        end
    end

    action ContinuedTouch(TouchEvent event)
        if event:fingerID = activeID
            distanceX = distanceX + event:GetMovementX()
            distanceY = distanceY + event:GetMovementY()
        end
    end

    action EndedTouch(TouchEvent event)
        if event:fingerID = activeID
            activeID = -1
        end
    end

end

EndedTouch(Libraries.Interface.Events.TouchEvent event)

This action is used to respond to a TouchEvent where the user's finger has just been lifted off of the screen. The event type of the provided TouchEvent should be either ENDED or CANCELLED.

Parameters

Example

class MyListener is TouchListener

    boolean isTouched = false

    action BeganTouch(TouchEvent event)
        isTouched = true
    end

    action EndedTouch(TouchEvent event)
        isTouched = false
    end

end

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()