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 TouchContinue

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
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.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
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.
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.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetHashCode()This action gets the hash code for an 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.

Example Code

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

    e

Parameters

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.

Example Code

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

Parameters

Return

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

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.

Example Code

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

    e

Parameters

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.

Example Code

class MyListener is TouchListener

        boolean isTouched = false

        action BeganTouch(TouchEvent event)
            isTouched = true
        end

        action EndedTouch(TouchEvent event)
            isTouched = false
        end

    e

Parameters

Equals(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode

Return

integer: The integer hash code of the object.