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:
|
||||
|
||||
# screen.new
|
||||
this function creates a new screen
|
||||
# CreateFrame
|
||||
this function creates a new frame
|
||||
````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>
|
||||
**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
|
||||
The same as screen, but it will have a parent frame
|
||||
The same as CreateFrame, but it will have a parent frame
|
||||
````lua
|
||||
frame:addFrame("myFirstFrame")
|
||||
````
|
||||
@@ -20,11 +17,11 @@ frame:addFrame("myFirstFrame")
|
||||
**returns:** a new frame object<br>
|
||||
Example:
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
local aFrame = aScreen:addFrame("myFirstFrame")
|
||||
local mainFrame = CreateFrame("myFirstFrame")
|
||||
local aFrame = mainFrame:addFrame("myFirstSubFrame")
|
||||
````
|
||||
# setTitle
|
||||
Changes the title from a frame or screen
|
||||
Changes the title from a frame
|
||||
````lua
|
||||
frame:setTitle("My first Frame!")
|
||||
````
|
||||
@@ -32,20 +29,20 @@ frame:setTitle("My first Frame!")
|
||||
**returns:** the frame object<br>
|
||||
Example:
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
local aFrame = aScreen:addFrame("myFirstFrame")
|
||||
local mainFrame = CreateFrame("myFirstFrame")
|
||||
local aFrame = MainFrame:addFrame("myFirstSubFrame")
|
||||
aFrame:setTitle("My first Frame!")
|
||||
````
|
||||
or:
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
local aFrame = aScreen:addFrame("myFirstFrame"):setTitle("My first Frame!")
|
||||
local mainFrame = CreateFrame("myFirstFrame")
|
||||
local aFrame = mainFrame:addFrame("myFirstSubFrame"):setTitle("My first Frame!")
|
||||
````
|
||||
|
||||
# setTitleAlign
|
||||
Sets the title alignment
|
||||
````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>
|
||||
**returns:** the frame object<br>
|
||||
@@ -55,7 +52,7 @@ local aScreen = screen.new("myFirstScreen"):setTitle("My first Frame!"):setTitle
|
||||
# setPosition
|
||||
Changes the position relative to its parent frame
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setPosition(2,3)
|
||||
local mainFrame = CreateFrame("myFirstFrame"):setPosition(2,3)
|
||||
````
|
||||
**args:** int x, int y<br>
|
||||
**returns:** the frame object<br>
|
||||
@@ -65,7 +62,7 @@ local aScreen = screen.new("myFirstScreen"):setPosition(2,3)
|
||||
# setBackground
|
||||
Changes the background color from the frame
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setBackground(colors.lightGray)
|
||||
local mainFrame = CreateFrame("myFirstFrame"):setBackground(colors.lightGray)
|
||||
````
|
||||
**args:** int color<br>
|
||||
**returns:** the frame object<br>
|
||||
@@ -73,7 +70,7 @@ local aScreen = screen.new("myFirstScreen"):setBackground(colors.lightGray)
|
||||
# setForeground
|
||||
Changes the text color from the frame
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setForeground(colors.black)
|
||||
local mainFrame = CreateFrame("myFirstFrame"):setForeground(colors.black)
|
||||
````
|
||||
**args:** int color<br>
|
||||
**returns:** the frame object<br>
|
||||
@@ -81,7 +78,7 @@ local aScreen = screen.new("myFirstScreen"):setForeground(colors.black)
|
||||
# setSize
|
||||
Changes the frame size
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setSize(15,5)
|
||||
local mainFrame = CreateFrame("myFirstFrame"):setSize(15,5)
|
||||
````
|
||||
**args:** int width, int length<br>
|
||||
**returns:** the frame object<br>
|
||||
@@ -89,7 +86,7 @@ local aScreen = screen.new("myFirstScreen"):setSize(15,5)
|
||||
# showBar
|
||||
shows/hides the bar on top where you will see the title if its active
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):showBar()
|
||||
local mainFrame = CreateFrame("myFirstFrame"):showBar()
|
||||
````
|
||||
**args:** bool isVisible (no args = true)<br>
|
||||
**returns:** the frame object<br>
|
||||
@@ -97,17 +94,17 @@ local aScreen = screen.new("myFirstScreen"):showBar()
|
||||
# isModifierActive
|
||||
returns true if user is currently holding a key
|
||||
````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>
|
||||
**returns:** true or false if the user is holding the key down<br>
|
||||
|
||||
**Example:**
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setSize(20,8):show()
|
||||
local aLabel = aScreen:addLabel("myFirstLabel"):setText("shift inactive")
|
||||
aScreen:addButton("myFirstButton"):setText("Click"):onClick(function()
|
||||
if(aScreen:isModifierActive("shift")then
|
||||
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")
|
||||
@@ -117,7 +114,7 @@ end)
|
||||
# show
|
||||
shows the frame on the screen
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):show()
|
||||
local mainFrame = CreateFrame("myFirstFrame"):show()
|
||||
````
|
||||
**args:** -<br>
|
||||
**returns:** the frame object<br>
|
||||
@@ -125,22 +122,22 @@ local aScreen = screen.new("myFirstScreen"):show()
|
||||
# hide
|
||||
hides the frame
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):hide()
|
||||
local mainFrame = CreateFrame("myFirstFrame"):hide()
|
||||
````
|
||||
**args:** -<br>
|
||||
**returns:** the frame object<br>
|
||||
**Example:**
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setSize(20,8):show()
|
||||
aScreen:addButton("myFirstButton"):setText("Exit"):onClick(function()
|
||||
aScreen:hide()
|
||||
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
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):remove()
|
||||
local mainFrame = CreateFrame("myFirstFrame"):remove()
|
||||
````
|
||||
**args:** -<br>
|
||||
**returns:** -<br>
|
||||
@@ -148,9 +145,9 @@ local aScreen = screen.new("myFirstScreen"):remove()
|
||||
# getObject
|
||||
returns a created object (arg = id)
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
aScreen:addButton("myFirstButton")
|
||||
local aButton = aScreen:getObject("myFirstButton")
|
||||
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<br>
|
||||
**returns:** object or nil<br>
|
||||
@@ -158,9 +155,9 @@ local aButton = aScreen:getObject("myFirstButton")
|
||||
# removeObject
|
||||
removes the object with the id
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
aScreen:addButton("myFirstButton")
|
||||
aScreen:removeObject("myFirstButton")
|
||||
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<br>
|
||||
**returns:** object or nil<br>
|
||||
@@ -168,18 +165,18 @@ aScreen:removeObject("myFirstButton")
|
||||
# setFocusedElement
|
||||
changes the currently focused element
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
local aButton = aScreen:addButton("myFirstButton")
|
||||
aScreen:setFocusedElement(aButton)
|
||||
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<br>
|
||||
**returns:** the frame object<br>
|
||||
# removeFocusedElement
|
||||
removes the focus of the currently focused element
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
local aButton = aScreen:addButton("myFirstButton")
|
||||
aScreen:removeFocusedElement(aButton)
|
||||
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<br>
|
||||
**returns:** the frame object<br>
|
||||
@@ -187,9 +184,9 @@ aScreen:removeFocusedElement(aButton)
|
||||
# getFocusedElement
|
||||
gets the currently focused element
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
local aButton = aScreen:addButton("myFirstButton")
|
||||
local focusedObject = aScreen:getFocusedElement()
|
||||
local mainFrame = CreateFrame("myFirstFrame")
|
||||
local aButton = mainFrame:addButton("myFirstButton")
|
||||
local focusedObject = mainFrame:getFocusedElement()
|
||||
````
|
||||
**args:** -<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)
|
||||
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setMoveable(true)
|
||||
local mainFrame = CreateFrame("myFirstFrame"):setMoveable(true)
|
||||
````
|
||||
**args:** bool<br>
|
||||
**returns:** object<br>
|
||||
|
||||
Reference in New Issue
Block a user