Skip to content
Caldas Lopes edited this page May 20, 2024 · 1 revision

Information

The form object is a Panel with Caption and Layout capabilities to serve as a base parent for other objects. Its usage can be seen on "Form" and "List" Demo examples.

Example Use

function love.load()
    loveframes = require("loveframes")

    local form = loveframes.Create("form")
    form:SetName("Form")

	for i=1, 3 do
		local button = loveframes.Create("button")
		button:SetText(i)
		button:SetWidth(400)
		form:AddItem(button)
	end
	
    form:CenterWithinArea(0, 0, love.graphics.getDimensions())
end

function love.update(dt)
    loveframes.update(dt)
end

function love.draw()
    loveframes.draw()
end

function love.mousepressed(x, y, button)
    loveframes.mousepressed(x, y, button)
end

function love.mousereleased(x, y, button)
    loveframes.mousereleased(x, y, button)
end

Methods

SetName

Sets the object's name

object:SetName(name[string])

GetName

Gets the object's name

Returns 1 value: object name [string]

local name = object:GetName()

SetLayoutType

Define children layout: "vertical" (Default) or "horizontal"

object:SetLayoutType(layout[string])

GetLayoutType

Gets layout type

Returns 1 value: object layout [string]

local layout = object:GetLayoutType()

SetTopMargin

Sets Top Margin

object:SetTopMargin(margin[integer])

GetTopMargin

Gets Top Margin

Returns 1 value: object margin [integer]

local margin = object:GetTopMargin()

LayoutObjects

Positions the object's children and calculates a new size for the object

Note: This method is used by the object internally. You should not use it unless you know what you are doing.

object:LayoutObjects()

AddItem

Adds an item to the form

object:AddItem(item[object])

RemoveItem

Removes an item from the form

object:RemoveItem(item[object])
object:RemoveItem(index[integer])

Clone this wiki locally