forked from cyborgize/LoveFrames
-
Notifications
You must be signed in to change notification settings - Fork 20
(API) Form
Caldas Lopes edited this page May 20, 2024
·
1 revision
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.
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)
endSets the object's name
object:SetName(name[string])Gets the object's name
Returns 1 value: object name [string]
local name = object:GetName()Define children layout: "vertical" (Default) or "horizontal"
object:SetLayoutType(layout[string])Gets layout type
Returns 1 value: object layout [string]
local layout = object:GetLayoutType()Sets Top Margin
object:SetTopMargin(margin[integer])Gets Top Margin
Returns 1 value: object margin [integer]
local margin = object:GetTopMargin()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()Adds an item to the form
object:AddItem(item[object])Removes an item from the form
object:RemoveItem(item[object])object:RemoveItem(index[integer])