Updated Frames (and Screens) (markdown)
@@ -1,18 +1,15 @@
|
|||||||
Frames are like screens or screens are frames. Frames can be sub objects of screens, while screens cannot be sub objects of frames OR screens. This is the only difference between screens and frames. Everything else is the same.
|
Here are all possible functions you can use with frames:
|
||||||
|
|
||||||
Here are all possible functions you can use with screens and frames:
|
# CreateFrame
|
||||||
|
this function creates a new frame
|
||||||
# screen.new
|
|
||||||
this function creates a new screen
|
|
||||||
````lua
|
````lua
|
||||||
local firstScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
````
|
````
|
||||||
**args:** string identifaction id. if you create 2 frames with the same id, the second one will return nil<br>
|
**args:** string identifaction id. if you create 2 frames with the same id, the second one will return nil<br>
|
||||||
**returns:** a new frame object
|
**returns:** a new frame object<br>
|
||||||
|
|
||||||
For what do i need screens? First, its your entry point for everything you want to create, second if you need multiple 'sub'-windows you create multiple screens
|
|
||||||
# addFrame
|
# addFrame
|
||||||
The same as screen, but it will have a parent frame
|
The same as CreateFrame, but it will have a parent frame
|
||||||
````lua
|
````lua
|
||||||
frame:addFrame("myFirstFrame")
|
frame:addFrame("myFirstFrame")
|
||||||
````
|
````
|
||||||
@@ -20,11 +17,11 @@ frame:addFrame("myFirstFrame")
|
|||||||
**returns:** a new frame object<br>
|
**returns:** a new frame object<br>
|
||||||
Example:
|
Example:
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
local aFrame = aScreen:addFrame("myFirstFrame")
|
local aFrame = mainFrame:addFrame("myFirstSubFrame")
|
||||||
````
|
````
|
||||||
# setTitle
|
# setTitle
|
||||||
Changes the title from a frame or screen
|
Changes the title from a frame
|
||||||
````lua
|
````lua
|
||||||
frame:setTitle("My first Frame!")
|
frame:setTitle("My first Frame!")
|
||||||
````
|
````
|
||||||
@@ -32,20 +29,20 @@ frame:setTitle("My first Frame!")
|
|||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
Example:
|
Example:
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
local aFrame = aScreen:addFrame("myFirstFrame")
|
local aFrame = MainFrame:addFrame("myFirstSubFrame")
|
||||||
aFrame:setTitle("My first Frame!")
|
aFrame:setTitle("My first Frame!")
|
||||||
````
|
````
|
||||||
or:
|
or:
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
local aFrame = aScreen:addFrame("myFirstFrame"):setTitle("My first Frame!")
|
local aFrame = mainFrame:addFrame("myFirstSubFrame"):setTitle("My first Frame!")
|
||||||
````
|
````
|
||||||
|
|
||||||
# setTitleAlign
|
# setTitleAlign
|
||||||
Sets the title alignment
|
Sets the title alignment
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):setTitle("My first Frame!"):setTitleAlign("right")
|
local mainFrame = CreateFrame("myFirstFrame"):setTitle("My first Frame!"):setTitleAlign("right")
|
||||||
````
|
````
|
||||||
**args:** string text - possible values: "left", "center", "right"<br>
|
**args:** string text - possible values: "left", "center", "right"<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
@@ -55,7 +52,7 @@ local aScreen = screen.new("myFirstScreen"):setTitle("My first Frame!"):setTitle
|
|||||||
# setPosition
|
# setPosition
|
||||||
Changes the position relative to its parent frame
|
Changes the position relative to its parent frame
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):setPosition(2,3)
|
local mainFrame = CreateFrame("myFirstFrame"):setPosition(2,3)
|
||||||
````
|
````
|
||||||
**args:** int x, int y<br>
|
**args:** int x, int y<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
@@ -65,7 +62,7 @@ local aScreen = screen.new("myFirstScreen"):setPosition(2,3)
|
|||||||
# setBackground
|
# setBackground
|
||||||
Changes the background color from the frame
|
Changes the background color from the frame
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):setBackground(colors.lightGray)
|
local mainFrame = CreateFrame("myFirstFrame"):setBackground(colors.lightGray)
|
||||||
````
|
````
|
||||||
**args:** int color<br>
|
**args:** int color<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
@@ -73,7 +70,7 @@ local aScreen = screen.new("myFirstScreen"):setBackground(colors.lightGray)
|
|||||||
# setForeground
|
# setForeground
|
||||||
Changes the text color from the frame
|
Changes the text color from the frame
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):setForeground(colors.black)
|
local mainFrame = CreateFrame("myFirstFrame"):setForeground(colors.black)
|
||||||
````
|
````
|
||||||
**args:** int color<br>
|
**args:** int color<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
@@ -81,7 +78,7 @@ local aScreen = screen.new("myFirstScreen"):setForeground(colors.black)
|
|||||||
# setSize
|
# setSize
|
||||||
Changes the frame size
|
Changes the frame size
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):setSize(15,5)
|
local mainFrame = CreateFrame("myFirstFrame"):setSize(15,5)
|
||||||
````
|
````
|
||||||
**args:** int width, int length<br>
|
**args:** int width, int length<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
@@ -89,7 +86,7 @@ local aScreen = screen.new("myFirstScreen"):setSize(15,5)
|
|||||||
# showBar
|
# showBar
|
||||||
shows/hides the bar on top where you will see the title if its active
|
shows/hides the bar on top where you will see the title if its active
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):showBar()
|
local mainFrame = CreateFrame("myFirstFrame"):showBar()
|
||||||
````
|
````
|
||||||
**args:** bool isVisible (no args = true)<br>
|
**args:** bool isVisible (no args = true)<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
@@ -97,17 +94,17 @@ local aScreen = screen.new("myFirstScreen"):showBar()
|
|||||||
# isModifierActive
|
# isModifierActive
|
||||||
returns true if user is currently holding a key
|
returns true if user is currently holding a key
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):isModifierActive("shift")
|
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"<br>
|
**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"<br>
|
||||||
**returns:** true or false if the user is holding the key down<br>
|
**returns:** true or false if the user is holding the key down<br>
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):setSize(20,8):show()
|
local mainFrame = CreateFrame("myFirstFrame"):setSize(20,8):show()
|
||||||
local aLabel = aScreen:addLabel("myFirstLabel"):setText("shift inactive")
|
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("shift inactive")
|
||||||
aScreen:addButton("myFirstButton"):setText("Click"):onClick(function()
|
mainFrame:addButton("myFirstButton"):setText("Click"):onClick(function()
|
||||||
if(aScreen:isModifierActive("shift")then
|
if(mainFrame:isModifierActive("shift")then
|
||||||
aLabel:setText("shift is active yay")
|
aLabel:setText("shift is active yay")
|
||||||
else
|
else
|
||||||
aLabel:setText("shift is not active ohno")
|
aLabel:setText("shift is not active ohno")
|
||||||
@@ -117,7 +114,7 @@ end)
|
|||||||
# show
|
# show
|
||||||
shows the frame on the screen
|
shows the frame on the screen
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):show()
|
local mainFrame = CreateFrame("myFirstFrame"):show()
|
||||||
````
|
````
|
||||||
**args:** -<br>
|
**args:** -<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
@@ -125,22 +122,22 @@ local aScreen = screen.new("myFirstScreen"):show()
|
|||||||
# hide
|
# hide
|
||||||
hides the frame
|
hides the frame
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):hide()
|
local mainFrame = CreateFrame("myFirstFrame"):hide()
|
||||||
````
|
````
|
||||||
**args:** -<br>
|
**args:** -<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
**Example:**
|
**Example:**
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):setSize(20,8):show()
|
local mainFrame = CreateFrame("myFirstFrame"):setSize(20,8):show()
|
||||||
aScreen:addButton("myFirstButton"):setText("Exit"):onClick(function()
|
mainFrame:addButton("myFirstButton"):setText("Exit"):onClick(function()
|
||||||
aScreen:hide()
|
mainFrame:hide()
|
||||||
end)
|
end)
|
||||||
````
|
````
|
||||||
|
|
||||||
# remove
|
# remove
|
||||||
removes the frame and its children objects completly
|
removes the frame and its children objects completly
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):remove()
|
local mainFrame = CreateFrame("myFirstFrame"):remove()
|
||||||
````
|
````
|
||||||
**args:** -<br>
|
**args:** -<br>
|
||||||
**returns:** -<br>
|
**returns:** -<br>
|
||||||
@@ -148,9 +145,9 @@ local aScreen = screen.new("myFirstScreen"):remove()
|
|||||||
# getObject
|
# getObject
|
||||||
returns a created object (arg = id)
|
returns a created object (arg = id)
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
aScreen:addButton("myFirstButton")
|
mainFrame:addButton("myFirstButton")
|
||||||
local aButton = aScreen:getObject("myFirstButton")
|
local aButton = mainFrame:getObject("myFirstButton")
|
||||||
````
|
````
|
||||||
**args:** the id of the created object (has to be a child from the frame<br>
|
**args:** the id of the created object (has to be a child from the frame<br>
|
||||||
**returns:** object or nil<br>
|
**returns:** object or nil<br>
|
||||||
@@ -158,9 +155,9 @@ local aButton = aScreen:getObject("myFirstButton")
|
|||||||
# removeObject
|
# removeObject
|
||||||
removes the object with the id
|
removes the object with the id
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
aScreen:addButton("myFirstButton")
|
mainFrame:addButton("myFirstButton")
|
||||||
aScreen:removeObject("myFirstButton")
|
mainFrame:removeObject("myFirstButton")
|
||||||
````
|
````
|
||||||
**args:** the id of the created object (has to be a child from the frame<br>
|
**args:** the id of the created object (has to be a child from the frame<br>
|
||||||
**returns:** object or nil<br>
|
**returns:** object or nil<br>
|
||||||
@@ -168,18 +165,18 @@ aScreen:removeObject("myFirstButton")
|
|||||||
# setFocusedElement
|
# setFocusedElement
|
||||||
changes the currently focused element
|
changes the currently focused element
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
local aButton = aScreen:addButton("myFirstButton")
|
local aButton = mainFrame:addButton("myFirstButton")
|
||||||
aScreen:setFocusedElement(aButton)
|
mainFrame:setFocusedElement(aButton)
|
||||||
````
|
````
|
||||||
**args:** the object you want to set as focus, has to be a children<br>
|
**args:** the object you want to set as focus, has to be a children<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
# removeFocusedElement
|
# removeFocusedElement
|
||||||
removes the focus of the currently focused element
|
removes the focus of the currently focused element
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
local aButton = aScreen:addButton("myFirstButton")
|
local aButton = mainFrame:addButton("myFirstButton")
|
||||||
aScreen:removeFocusedElement(aButton)
|
mainFrame:removeFocusedElement(aButton)
|
||||||
````
|
````
|
||||||
**args:** the object you want to set as focus, has to be a children<br>
|
**args:** the object you want to set as focus, has to be a children<br>
|
||||||
**returns:** the frame object<br>
|
**returns:** the frame object<br>
|
||||||
@@ -187,9 +184,9 @@ aScreen:removeFocusedElement(aButton)
|
|||||||
# getFocusedElement
|
# getFocusedElement
|
||||||
gets the currently focused element
|
gets the currently focused element
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local mainFrame = CreateFrame("myFirstFrame")
|
||||||
local aButton = aScreen:addButton("myFirstButton")
|
local aButton = mainFrame:addButton("myFirstButton")
|
||||||
local focusedObject = aScreen:getFocusedElement()
|
local focusedObject = mainFrame:getFocusedElement()
|
||||||
````
|
````
|
||||||
**args:** -<br>
|
**args:** -<br>
|
||||||
**returns:** object<br>
|
**returns:** object<br>
|
||||||
@@ -198,7 +195,7 @@ local focusedObject = aScreen:getFocusedElement()
|
|||||||
sets if the frame should be moveable or not (to move the frame you need to drag it on the top bar)
|
sets if the frame should be moveable or not (to move the frame you need to drag it on the top bar)
|
||||||
|
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen"):setMoveable(true)
|
local mainFrame = CreateFrame("myFirstFrame"):setMoveable(true)
|
||||||
````
|
````
|
||||||
**args:** bool<br>
|
**args:** bool<br>
|
||||||
**returns:** object<br>
|
**returns:** object<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user