Skip to content
Robert Jelic edited this page May 2, 2022 · 25 revisions

Frames are like containers, but are also normal objects. Means, you can add other objects (even frames) to a frame and if the frame itself is visible, all sub objects (if they are set to visible by :show()) are also visible. A better description will follow.

basalt.createFrame

creates a new non-parent frame - in most cases the first thing you need.

local mainFrame = basalt.createFrame("myFirstFrame")

args: string name (should be unique)
returns: new frame object

addFrame

The same as basalt.createFrame, but it will have a parent frame

frame:addFrame("myFirstFrame")

args: string name (should be unique)
returns: new frame object
Example:

local mainFrame = basalt.createFrame("myFirstFrame")
local aFrame = mainFrame:addFrame("myFirstSubFrame")

setBar

Changes the frame bar

frame:setBar("My first Frame!", colors.gray, colors.lightGray)

args: string text, number bgcolor, number fgcolor
returns: self
Example:

local mainFrame = basalt.createFrame("myFirstFrame")
local aFrame = MainFrame:addFrame("myFirstSubFrame")
aFrame:setBar("My first Frame!")

or:

local mainFrame = basalt.createFrame("myFirstFrame")
local aFrame = mainFrame:addFrame("myFirstSubFrame"):setBar("My first Frame!")

setBarTextAlign

Sets the bar text alignment

local mainFrame = basalt.createFrame("myFirstFrame"):setBar("My first Frame!"):setBarTextAlign("right")

args: string value - ("left", "center", "right"))
returns: self

showBar

shows/hides the bar on top where you will see the title if its active

local mainFrame = basalt.createFrame("myFirstFrame")setBar("Hello World!"):showBar()

args: bool visible (no args = true)
returns: self

isModifierActive

returns true if user is currently holding a key down

local mainFrame = basalt.createFrame("myFirstFrame"):isModifierActive("shift")

args: int or string - int can be any os.queueEvent("key") key, or instead of int you can use the following strings: "shift", "ctrl", "alt"
returns: boolean - if the user is holding the key down

Example:

local mainFrame = basalt.createFrame("myFirstFrame"):setSize(20,8):show()
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("shift inactive")
mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function()
if(mainFrame:isModifierActive("shift")then
    aLabel:setText("shift is active yay")
else
    aLabel:setText("shift is not active ohno")
end)

getObject

returns a children object

local mainFrame = basalt.createFrame("myFirstFrame")
mainFrame:addButton("myFirstButton")
local aButton = mainFrame:getObject("myFirstButton")

args: string name (has to be a children)
returns: any object

removeObject

removes the object

local mainFrame = basalt.createFrame("myFirstFrame")
mainFrame:addButton("myFirstButton")
mainFrame:removeObject("myFirstButton")

args: string name (has to be a children)
returns: any object

setFocusedObject

changes the currently focused object

local mainFrame = basalt.createFrame("myFirstFrame")
local aButton = mainFrame:addButton("myFirstButton")
mainFrame:setFocusedObject(aButton)

args: any object (has to be a children)
returns: self

removeFocusedObject

removes the focus of the currently focused object

local mainFrame = basalt.createFrame("myFirstFrame")
local aButton = mainFrame:addButton("myFirstButton")
mainFrame:removeFocusedObject(aButton)

args: any object (has to be a children)
returns: self

getFocusedObject

gets the currently focused object

local mainFrame = basalt.createFrame("myFirstFrame")
local aButton = mainFrame:addButton("myFirstButton")
local focusedObject = mainFrame:getFocusedObject()

args: -
returns: object

setMoveable

sets if the frame should be moveable or not (to move the frame you need to drag it on the top bar)

local mainFrame = basalt.createFrame("myFirstFrame"):setMoveable(true)

args: bool moveable
returns: self

setOffset

sets the frame's coordinate offset, they will get added to their children objects. For example, if you use the scrollbar and you use its value to add a offset to a frame, you will get a scrollable frame. objects are also able to ignore the offset by using :ignoreOffset() (maybe your scrollbar if its a children of the frame should ignore offset)

local mainFrame = basalt.createFrame("myFirstFrame"):setOffset(5, 3)

args: number x, number y (offset in x direction and offset in y direction, also doesn't matter if its a negative value or positive
returns: self

Wiki Navigation

Home

Clone this wiki locally