Libraries.Interface.Forms.FormPanel Documentation

Inherits from: Libraries.Interface.Item, Libraries.Interface.Controls.Control, Libraries.Interface.Item2D, Libraries.Interface.Forms.FormContainerControl, 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

AddButton(text name)

This action adds a button to the control.

Parameters

  • text name: The text name identifying the button.

Return

Libraries.Interface.Controls.Button: The button object created when the AddButton(text) action is called.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.Button

class Main
    action Main
        Form form
        Page page = form:GetMainPage()
        Button button = page:AddButton("my button")

        form:Display()
    end
end

AddButton(text name, text fileName)

This action adds a button with an icon to the control.

Parameters

  • text name: The text name identifying the button.
  • text fileName: The text file path to where the image used as the button icon is located.

Return

Libraries.Interface.Controls.Button: The button object created when the AddButton(text, text) action is called.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.Button

class Main
    action Main
        Form form
        Page page = form:GetMainPage()
        Button button = page:AddButton("my button", "Images/adoptUs.png")

        form:Display()
    end
end

AddCheckbox(text name)

This action adds a checkbox to the control.

Parameters

  • text name: The text name identifying the checkbox.

Return

Libraries.Interface.Controls.Checkbox: The checkbox object that was added to the control.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.Checkbox

class Main
    action Main
        // create the app
        Form form
        Page homePage = form:GetMainPage() 

        Checkbox field = homePage:AddCheckbox("my checkbox")
        
        form:Display()
    end
end

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)

AddIcon(text name, text fileName)

This action adds an icon(image) to the control.

Parameters

  • text name: The text name identifying the icon.
  • text fileName: The text path to the image.

Return

Libraries.Interface.Controls.Icon: The icon object that was added to the control.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page

class Main
    action Main
        // create the app
        Form form
        Page homePage = form:GetMainPage() 

        homePage:AddIcon("my icon", "Images/Blue Jay.png")
        
        form:Display()
    end
end

AddLabel(text name)

This action adds a label to the control.

Parameters

  • text name: The text name identifying the label.

Return

Libraries.Game.Graphics.Label: The label object that was added to the control.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page

class Main
    action Main
        // create the app
        Form form
        Page homePage = form:GetMainPage() 

        homePage:AddLabel("my label")
        
        form:Display()
    end
end

AddLabel(text name, text value)

This action adds a label to the control.

Parameters

  • text name: The text name identifying the label.
  • text value: The text displayed in the label.

Return

Libraries.Game.Graphics.Label: The label object that was added to the control.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page

class Main
    action Main
        // create the app
        Form form
        Page homePage = form:GetMainPage() 

        homePage:AddLabel("my label", "Name: ")
        
        form:Display()
    end
end

AddLayoutProperties(Libraries.Interface.Layouts.LayoutProperties properties)

Returns true if rendering the mouse down event.

Parameters

AddList(text name)

This action adds a list to the control.

Parameters

  • text name: The text name identifying the list.

Return

Libraries.Interface.Controls.List: The list object that was added to the control.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page

class Main
    action Main

        Form form
        Page homePage = form:GetMainPage() 

        homePage:AddList("list")
        
        form:Display()
    end
end

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

AddTextBox(text name)

This action adds a text box to the control.

Parameters

  • text name: The text name identifying the text box.

Return

Libraries.Interface.Controls.TextBox: The text box object that was added to the control.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.TextBox

class Main
    action Main
        // create the app
        Form form
        Page homePage = form:GetMainPage() 

        TextBox field = homePage:AddTextBox("my textbox")
        
        form:Display()
    end
end

AddTextField(text name)

This action adds a text field to the control.

Parameters

  • text name: The text name identifying the text field.

Return

Libraries.Interface.Controls.TextField: The text field object that was added to the control.

Example

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.TextField

class Main
    action Main
        // create the app
        Form form
        Page homePage = form:GetMainPage() 

        TextField field = homePage:AddTextField("my field")
        
        form:Display()
    end
end

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

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.

CalculateDefaultFocusOrdering()

Forms by default can calculate a default ordering for focus across a set of controls. This means that if this action is called, the system will dig through the form that is being created and calculate such an order. This action is intentionally limited and, while it works for default cases and typical controls, callers should recognize that complex or highly custom forms will likely require additional work. Put another way, focus orderings are typically not one size fits all, even if this action tries to calculate sensible defaults under many common conditions.

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.

CenterAlignContent()

This action aligns any content in the control to the center.

CenterAlignTitle()

This action aligns the title on the form control to the center.

ChangeButtonIcon(text name, text fileName)

This action changes the icon(image) on a button in the control. This action should only be used when the button is created and displayed on the form (after form:Display() is called).

Parameters

  • text name: The text name identifying the button.
  • text fileName: The path of the image to use as the button icon.

Example

use Libraries.Interface.Events.BehaviorEvent
use Libraries.Interface.Forms.FormBehavior
use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Item
use Libraries.Interface.Controls.Button

class Main is FormBehavior
    action Main
        // create the app
        Form form
        
        Page homePage = form:GetMainPage() 
        Button button = homePage:AddButton("my button", "Images/Blue Jay.png")
        
        button:SetBehavior(me)
        
        form:Display()
    end

    action Run(BehaviorEvent event)
        Form form = GetForm()
        Page page = GetPage()
        
        page:ChangeButtonIcon("my button", "Images/adoptUs.png")
    end
end