Skip to content
Robert Jelic edited this page Mar 30, 2022 · 25 revisions

Here are all possible functions you can use with frames:

CreateFrame

this function creates a new frame

local mainFrame = CreateFrame("myFirstFrame")

args: string identifaction id. if you create 2 frames with the same id, the second one will return nil
returns: a new frame object

addFrame

The same as CreateFrame, but it will have a parent frame

frame:addFrame("myFirstFrame")

args: string identifaction id. if you create 2 frames with the same id, the second one will return nil
returns: a new frame object
Example:

local mainFrame = CreateFrame("myFirstFrame")
local aFrame = mainFrame:addFrame("myFirstSubFrame")

setTitle

Changes the title from a frame

frame:setTitle("My first Frame!")

args: string text
returns: the frame object
Example:

local mainFrame = CreateFrame("myFirstFrame")
local aFrame = MainFrame:addFrame("myFirstSubFrame")
aFrame:setTitle("My first Frame!")

or:

local mainFrame = CreateFrame("myFirstFrame")
local aFrame = mainFrame:addFrame("myFirstSubFrame"):setTitle("My first Frame!")

setTitleAlign

Sets the title alignment

local mainFrame = CreateFrame("myFirstFrame"):setTitle("My first Frame!"):setTitleAlign("right")

args: string text - possible values: "left", "center", "right"
returns: the frame object

setPosition

Changes the position relative to its parent frame

local mainFrame = CreateFrame("myFirstFrame"):setPosition(2,3)

args: int x, int y
returns: the frame object

setBackground

Changes the background color from the frame

local mainFrame = CreateFrame("myFirstFrame"):setBackground(colors.lightGray)

args: int color
returns: the frame object

setForeground

Changes the text color from the frame

local mainFrame = CreateFrame("myFirstFrame"):setForeground(colors.black)

args: int color
returns: the frame object

setSize

Changes the frame size

local mainFrame = CreateFrame("myFirstFrame"):setSize(15,5)

args: int width, int length
returns: the frame object

showBar

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

local mainFrame = CreateFrame("myFirstFrame"):showBar()

args: bool isVisible (no args = true)
returns: the frame object

isModifierActive

returns true if user is currently holding a key

local mainFrame = 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: true or false if the user is holding the key down

Example:

local mainFrame = 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)

show

shows the frame on the screen

local mainFrame = CreateFrame("myFirstFrame"):show()

args: -
returns: the frame object

hide

hides the frame

local mainFrame = CreateFrame("myFirstFrame"):hide()

args: -
returns: the frame object
Example:

local mainFrame = CreateFrame("myFirstFrame"):setSize(20,8):show()
mainFrame:addButton("myFirstButton"):setText("Exit"):onClick(function()
    mainFrame:hide()
end)

remove

removes the frame and its children objects completly

local mainFrame = CreateFrame("myFirstFrame"):remove()

args: -
returns: -

getObject

returns a created object (arg = id)

local mainFrame = CreateFrame("myFirstFrame")
mainFrame:addButton("myFirstButton")
local aButton = mainFrame:getObject("myFirstButton")

args: the id of the created object (has to be a child from the frame
returns: object or nil

removeObject

removes the object with the id

local mainFrame = CreateFrame("myFirstFrame")
mainFrame:addButton("myFirstButton")
mainFrame:removeObject("myFirstButton")

args: the id of the created object (has to be a child from the frame
returns: object or nil

setFocusedElement

changes the currently focused element

local mainFrame = CreateFrame("myFirstFrame")
local aButton = mainFrame:addButton("myFirstButton")
mainFrame:setFocusedElement(aButton)

args: the object you want to set as focus, has to be a children
returns: the frame object

removeFocusedElement

removes the focus of the currently focused element

local mainFrame = CreateFrame("myFirstFrame")
local aButton = mainFrame:addButton("myFirstButton")
mainFrame:removeFocusedElement(aButton)

args: the object you want to set as focus, has to be a children
returns: the frame object

getFocusedElement

gets the currently focused element

local mainFrame = CreateFrame("myFirstFrame")
local aButton = mainFrame:addButton("myFirstButton")
local focusedObject = mainFrame:getFocusedElement()

args: -
returns: object

setMoveable(bool)

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

local mainFrame = CreateFrame("myFirstFrame"):setMoveable(true)

args: bool
returns: object

Wiki Navigation

Home

Clone this wiki locally