Libraries.Interface.Controls.TextField Documentation

The TextField class is a control object and UI element it is added to the Game class. The TextField is used to represent a general text area that contains a single line of text.

Example Code

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.TextField
use Libraries.Game.Graphics.Color

class Main 
    action Main 
        Form form
        Page page = form:GetMainPage()

        TextField field
        Color color
        field:SetName("myTxt")
        field:SetBackgroundColor(color:Green())
        page:Add(field)

        form:Display()
    end
end

Inherits from: Libraries.Interface.Events.FocusListener, Libraries.Interface.Controls.Control, Libraries.Interface.Events.MouseMovementListener, Libraries.Interface.Item, Libraries.Interface.Item2D, Libraries.Interface.Events.MouseListener, Libraries.Language.Object

Actions Documentation

Activate(Libraries.Interface.Events.BehaviorEvent event)

Returns true if rendering the focus event.

Parameters

Activate()

This action returns a default behavior for this paricular control. Some controls do nothing by default, like a TextBox that responds to different kinds of input. Others, however, have default behaviors, like a Button or a MenuItem. If there is no default behavior, this action returns undefined.

Add(integer index, Libraries.Interface.Item2D newItem)

This action adds a different Item2D into this one, storing the added Item2D at a specific index in the internal array.

Parameters

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
parentItem:Add(0, child)

Add(Libraries.Interface.Item2D newItem)

This action adds a different Item2D into this one. This makes a few things happen. 1. The added item will get this item as its parent. 2. The added item's x and y coordinates will become relative to this Item. 3. Most actions on this Item will also affect the added Item.

Parameters

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
parentItem:Add(child)

AddBehavior(Libraries.Interface.Behaviors.Behavior behavior)

This action adds a new Behavior to this Item.

Parameters

AddControlActivationListener(Libraries.Interface.Events.ControlActivationListener listener)

This action removes an Item2D at a specifed index from the internal array.

Parameters

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
parentItem:Add(0, child)
parentItem:Remove(0)

AddFocusListener(Libraries.Interface.Events.FocusListener listener)

This action adds a FocusListener to the Item. When the Item receives a FocusEvent due to either gaining or losing the focus, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.FocusListener
Item myItem
FocusListener listener
myItem:AddFocusListener(listener)

AddGestureListener(Libraries.Interface.Events.GestureListener listener)

This action adds a GestureListener to the Item. If the Item ever receives a GestureEvent, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.GestureListener
Item myItem
GestureListener listener
myItem:AddGestureListener(listener)

AddLayoutProperties(Libraries.Interface.Layouts.LayoutProperties properties)

Returns true if rendering the mouse down event.

Parameters

AddMouseListener(Libraries.Interface.Events.MouseListener listener)

This action adds a MouseListener to the Item. If the Item ever receives a MouseEvent due to a mouse click, the mouse listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseListener
Item myItem
MouseListener listener
myItem:AddMouseListener(listener)

AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action adds a MouseMovementListener to the Item. If the Item ever receives a MouseEvent due to mouse movement, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseMovementListener
Item myItem
MouseMovementListener listener
myItem:AddMouseMovementListener(listener)

AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action adds a MouseWheelListener to the Item. If the Item ever receives a MouseEvent due to the mouse wheel being scrolled, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseWheelListener
Item myItem
MouseWheelListener listener
myItem:AddMouseWheelListener(listener)

AddSelectionListener(Libraries.Interface.Events.SelectionListener listener)

This action adds the given SelectionListeners to the Control.

Parameters

AddTextChangeListener(Libraries.Interface.Events.TextChangeListener listener)

This action gets the selection from the text field.

Parameters

AddTouchListener(Libraries.Interface.Events.TouchListener listener)

This action adds a TouchListener to the Item. If the Item ever receives a TouchEvent, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.TouchListener
Item myItem
TouchListener listener
myItem:AddTouchListener(listener)

Advance(number time)

This action is used to advance the item forward in time in physics space to synchronize it for time of impact solving. This action is used internally and users should not need to use this action. Attribute Parameter time The amount of seconds to advance the item forward in time

Parameters

  • number time

AppendToText(text value)

This action adds to the text in the text field a specified value at the end.

Parameters

  • text value: the text to be placed at the end of the text field.

ApplyAngularImpulse(number impulse)

This action applies an angular impulse to this item. The units are in kilogram units squared per second. This modifies the angular velocity of this item. Physics must be enabled on this item before using this action.

Parameters

  • number impulse: The angular impulse in kilogram units squared per second

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:ApplyAngularImpulse(80)

ApplyForce(Libraries.Compute.Vector2 force, Libraries.Compute.Vector2 point)

This action applies a force to this item at the passed point. The force is in kilogram units per second per second. The point is the screen coordinates where the point will be applied. If the point is not on the center of the item, then a torque will be introduced causing the item to rotate. Physics must be enabled on this item before using this action.

Parameters

Example

use Libraries.Compute.Vector2
use Libraries.Interface.Item2D

Item2D item
Vector2 force
Vector2 point

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

force:Set(300, 350)
point:Set(100, 100)    // apply the force to the top right corner of the item

item:ApplyForce(force, point)

ApplyForceToCenter(Libraries.Compute.Vector2 force)

This action applies a force to this item at the center of the item. The force is in kilogram units per second per second. No torque is introduced to the item when using this action. Physics must be enabled on this item before using this action.

Parameters

Example

use Libraries.Compute.Vector2
use Libraries.Interface.Item2D

Item2D item
Vector2 force

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

force:Set(300, 350)

item:ApplyForce(force)

ApplyLinearImpulse(Libraries.Compute.Vector2 impulse, Libraries.Compute.Vector2 point)

This action applies a linear impulse to this item at the passed point. The impulse is in kilogram units per second. This immeadietly modifies the linear velocity of this item. The point is the screen coordinates where the impulse will be applied. If the point is not the center of the item, then the angular velocity of this item will also be modified. Physics must be enabled on this item before using this action.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 impulse
Vector2 point

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

impulse:Set(100)
point:Set(100, 100)     // apply the impulse to the top right corner

item:ApplyLinearImpulse(impulse, point)

ApplyTorque(number torque)

This action applies a torque to this item. The units are kilogram units squared per second per second. Physics must be enabled on this item before using this action.

Parameters

  • number torque: The torque to apply to this item in kilogram units squared per second per second

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:ApplyTorque(350)

AreChildrenProcessingMouseEvents()

This action returns whether or not this Item is allowing its children to receive mouse events if the Item is custom drawing. If the Item isn't using custom drawing, this value is irrelevant -- children objects always receive mouse events before the parent if the parent isn't performing custom drawing.

Return

boolean:

BeginCollision(Libraries.Interface.Item item)

This action is used to indicate that two items have just begun colliding. When two Items collide, the BeginCollision action should be called on both of them, with the other item passed as a parameter to the action. Note that this action does nothing by default, but classes that inherit from Item may override it.

Parameters

Example

use Libraries.Interface.Item

Item collider1
Item collider2
collider1:BeginCollision(collider2)
collider2:BeginCollision(collider1)

BeginMouseOver()

This action is used when a control is moused over by the mouse.

CanRotate(boolean flag)

This action gets the position of the center of this item in global (world) coordinates.

Parameters

  • boolean flag

CancelBehaviors()

This action stops all behaviors this Item is following without finishing them.

ClickedMouse()

This action is used when a control is clicked by the mouse.

ClickedMouse(Libraries.Interface.Events.MouseEvent event)

This action inserts the given text into the text fields text at a given location in the text fields content.

Parameters

CollideWithChildren()

This action sets the mass, mass moment of inertia, and how the 2D item should move (via linear velocity) to be at the desired location.

Return

boolean:

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)

ComputeDistance(Libraries.Compute.Vector2 point, integer childIndex, Libraries.Compute.Vector2 normalOut)

This action computes the distance of the passed point from the collision shape attached to this item. This action is used internally and users should not need to use this action.

Parameters

  • Libraries.Compute.Vector2: The vector representing the point to compute the distance from
  • integer childIndex: The index of the collision shape attached to this item we want the bounding box of
  • Libraries.Compute.Vector2: The direction of the point from the shape

Return

number: The distance of the point from the collision shape of this item

Contains(number containsX, number containsY)

This action tests if a point in global x,y coordinates is contained inside this Item2D. The global coordinates are considered to be the x and y coordinates of this Item plus its offsetX and offsetY values.

Parameters

  • number containsX
  • number containsY

Return

boolean: Whether or not the point is contained in this Item.

Example

use Libraries.Interface.Item2D

Item2D item
item:SetPosition(50, 50)
item:SetWidth(100)
item:SetHeight(50)
boolean value = item:Contains(125, 70)

CopyAndActivateInputTable(text name)

This action obtains the Input Table from this control, copies it, assigns it a group name, sets the control to use the new input table, and then adds it to the global input table hash table.

Parameters

  • text name: the name of the group for the new input table.

Return

Libraries.Game.InputTable: the input table copy

Example

use Libraries.Game.Game
use Libraries.Interface.Controls.TextBox
use Libraries.Game.InputTable

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        TextBox box
        InputTable copy = box:CopyAndActivateInputTable("New Group")
    end

    action Update(number seconds)
    end
end

CreateNodes(Libraries.Game.Collision.BroadphaseCollision2D broadphase, Libraries.Game.Collision.PhysicsPosition2D transform)

This action creates the nodes for this item for the broadphase collision. This action is needed in order to add the item to the collision detection system. This action is used internally and users should not need to use this action.

Parameters

Delete(integer startIndex, integer endIndex)

This action deletes the characters in the string of text from the given start and end indexes.

Parameters

  • integer startIndex: the first character location.
  • integer endIndex: the last character location.

DeleteBackward()

This action deletes the character behind the caret (left) or the selected text.

DeleteForward()

This action deletes the character in front of the caret (right) or the selected text.

DeleteSelection()

This action deletes the selected text.