-
Notifications
You must be signed in to change notification settings - Fork 43
Object
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:
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
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
Changes the object background color
local mainFrame = NyoUI.createFrame("myFirstFrame"):setBackground(colors.lightGray)
args: int color
returns: the object
Changes the object text color
local mainFrame = NyoUI.createFrame("myFirstFrame"):setForeground(colors.black)
args: int color
returns: the object
Changes the object size
local mainFrame = NyoUI.createFrame("myFirstFrame"):setSize(15,5)
args: width, length
returns: the object
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
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
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
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
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
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
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
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
WIP
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
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
WIP done but buggy have to look
WIP done but buggy have to look
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
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
returns the given name of that object
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
NyoUI.debug(mainFrame:getName()) -- returns myFirstFrame
args:-
returns: returns the name
These object events are available for all objects, if a object got some unique events, you can see them in their own category
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
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
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
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
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
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
creates a get focus event
local mainFrame = NyoUI.createFrame("myFirstFrame"):onGetFocus(function(self) NyoUI.debug("thanks!") end):show()
args: function
returns: the object
Thanks for checking out our wiki, join our discord for more help: discord.gg/yM7kndJdJJ