Skip to content
Robert Jelic edited this page Apr 2, 2022 · 14 revisions

All the functions you can see here are available for all objects! It doesn't matter if its a frame or a button or a list (or something else).

Here is a list of possible functions:

show

shows the object (only if the parent frame is already visible)

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local button = mainFrame:addButton("myFirstButton")
button:show()

args: -
returns: the object

hide

hides the object

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local button = mainFrame:addButton("myFirstButton"):setText("Close"):onClick(function() mainFrame:hide() end)
button:show()
````s
**args:** -<br>
**returns:** the object<br>

# setPosition
Changes the position relative to its parent frame
````lua
local mainFrame = NyoUI.createFrame("myFirstFrame"):setPosition(2,3)

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

setBackground

Changes the object background color

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

args: int color
returns: the object

setForeground

Changes the object text color

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

args: int color
returns: the object

setSize

Changes the object size

local mainFrame = NyoUI.createFrame("myFirstFrame"):setSize(15,5)

args: width, length
returns: the object

setFocus

sets the object to be the focused object

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setFocus():show()

args: -
returns: the object

setZIndex

changes the z index (lower z index do have higher draw priority)

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):show()

args: index
returns: the object

setParent

changes the frame parent of that object

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aRandomFrame = NyoUI.createFrame("aRandomFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):onClick(function() aRandomFrame:setParent(mainFrame) end):show()

args: frame object
returns: the object

isFocusedObject

returns if the object is currently the focused object of the parent frame

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):show()
NyoUI.debug(aButton:isFocusedObject()) -- shows true or false as a debug message

args: -
returns: true or false

getAnchorPosition

converts the x,y coordinates into the anchor coordinates of that object

local mainFrame = NyoUI.createFrame("myFirstFrame"):setSize(15,15):show()
local aButton = mainFrame:addButton("myFirstButton"):setAnchor("right","bottom"):setSize(8,1):setPosition(1,1):show()
NyoUI.debug(aButton:getAnchorPosition()) -- returns 7,14 (framesize - own size) instead of 1,1

args: x,y or nothing - if nothing it uses the object x,y
returns: converted coordinates

setAnchor

sets the anchor of that object

local mainFrame = NyoUI.createFrame("myFirstFrame"):setAnchor("right"):show()
local aButton = mainFrame:addButton("myFirstButton"):setAnchor("bottom","right"):setSize(8,1):setPosition(1,1):show()

args: "left", "right", "top", "bottom" - doesn't matter which order
returns: the object

relativeToAbsolutePosition

converts the relative coordinates into absolute coordinates

local mainFrame = NyoUI.createFrame("myFirstFrame"):setPosition(3,3):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(8,1):setPosition(4,2):show()
NyoUI.debug(aButton:relativeToAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2

args: x,y or nothing - if nothing it uses the object x,y
returns: the object

setTextAlign

sets the align of the object (as example buttons)

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(12,3):setTextAlign("right", "center"):setText("Dont't..."):show()

args: horizontal,vertical you can use "left", "center", "right"
returns: the object

setCustomArgs

WIP

setValue

sets the value of that object (input, label, checkbox, textfield, scrollbar,...)

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()

args: value (text,checked,number,...)
returns: the object

getValue

returns the currently saved value

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
NyoUI.debug(aCheckbox:getValue()) -- returns true

args:-
returns: the value

isLinked

WIP done but buggy have to look

linkTo

WIP done but buggy have to look

getHeight/getWidth

returns the height or width of that object

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show()
NyoUI.debug(aButton:getHeight()) -- returns 8

args:-
returns: returns the height or the width

isVisible

returns if the object is currently visible

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(5,8):show()
NyoUI.debug(aButton:isVisible()) -- returns true

args:-
returns: returns the visible state of that object

getName

returns the given name of that object

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
NyoUI.debug(mainFrame:getName()) -- returns myFirstFrame

args:-
returns: returns the name

Object Events

These object events are available for all objects, if a object got some unique events, you can see them in their own category

onClick

creates a mouse_click event

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClick(function(self,event,button,x,y) NyoUI.debug("Hellooww UwU") end):show()

args: function
returns: the object

onClickUp

creates a click_up event

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) NyoUI.debug("Byeeeee UwU") end):show()

args: function
returns: the object

onMouseDrag

creates a mouse_drag event

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myFirstButton"):setSize(10,3):onClickUp(function(self,event,button,x,y) NyoUI.debug("Byeeeee UwU") end):show()

args: function
returns: the object

onChange

creates a change event (fires as soon as the value gets changed)

local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) NyoUI.debug("i got changed into "..self:getValue()) end):show()

args: function
returns: the object

onKey

creates a key(board) - event can be key or char

local mainFrame = NyoUI.createFrame("myFirstFrame"):onKey(function(self,event,key) NyoUI.debug("you clicked "..key) end):show()

args: function
returns: the object

onLoseFocus

creates a lose focus event

local mainFrame = NyoUI.createFrame("myFirstFrame"):onLoseFocus(function(self) NyoUI.debug("please come back..") end):show()

args: function
returns: the object

onGetFocus

creates a get focus event

local mainFrame = NyoUI.createFrame("myFirstFrame"):onGetFocus(function(self) NyoUI.debug("thanks!") end):show()

args: function
returns: the object

Wiki Navigation

Home
Clone this wiki locally