Updated Frames (& Screens) (markdown)
@@ -7,15 +7,15 @@ this function creates a new screen
|
|||||||
````lua
|
````lua
|
||||||
local firstScreen = screen.new("myFirstScreen")
|
local firstScreen = screen.new("myFirstScreen")
|
||||||
````
|
````
|
||||||
par: string identifaction id. if you create 2 frames with the same id, the second one will return nil
|
**args:** string identifaction id. if you create 2 frames with the same id, the second one will return nil<br>
|
||||||
returns a frame object
|
**returns:** a new frame object
|
||||||
# frame:addFrame
|
# frame:addFrame
|
||||||
The same as screen, but this will have parent frames (like screens)
|
The same as screen, but it will have a parent frame
|
||||||
````lua
|
````lua
|
||||||
frame:addFrame("myFirstFrame")
|
frame:addFrame("myFirstFrame")
|
||||||
````
|
````
|
||||||
par: string identifaction id. if you create 2 frames with the same id, the second one will return nil
|
**args:** string identifaction id. if you create 2 frames with the same id, the second one will return nil<br>
|
||||||
returns a frame object
|
**returns:** a new frame object
|
||||||
Example:
|
Example:
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local aScreen = screen.new("myFirstScreen")
|
||||||
@@ -24,41 +24,190 @@ local aFrame = aScreen:addFrame("myFirstFrame")
|
|||||||
# frame:setTitle
|
# frame:setTitle
|
||||||
Changes the title from a frame or screen
|
Changes the title from a frame or screen
|
||||||
````lua
|
````lua
|
||||||
frame:setTitle("My first Frame!)
|
frame:setTitle("My first Frame!")
|
||||||
````
|
````
|
||||||
par: string text
|
**args:** string text<br>
|
||||||
returns the frame object
|
**returns:** the frame object
|
||||||
Example:
|
Example:
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local aScreen = screen.new("myFirstScreen")
|
||||||
local aFrame = aScreen:addFrame("myFirstFrame")
|
local aFrame = aScreen:addFrame("myFirstFrame")
|
||||||
aFrame:setTitle("My first Frame!)
|
aFrame:setTitle("My first Frame!")
|
||||||
````
|
````
|
||||||
or:
|
or:
|
||||||
````lua
|
````lua
|
||||||
local aScreen = screen.new("myFirstScreen")
|
local aScreen = screen.new("myFirstScreen")
|
||||||
local aFrame = aScreen:addFrame("myFirstFrame"):setTitle("My first Frame!)
|
local aFrame = aScreen:addFrame("myFirstFrame"):setTitle("My first Frame!")
|
||||||
````
|
````
|
||||||
--WIP FROM HERE
|
|
||||||
# frame:setTitleAlign(string) -- sets the title alignment ("left","right","center")
|
# frame:setTitleAlign
|
||||||
# frame:setPosition(int, int) -- changes the position relative to its parent frame
|
Sets the title alignment
|
||||||
# frame:setBackground(int) -- changes the background color
|
````lua
|
||||||
# frame:setForeground(int) -- changes the text color
|
local aScreen = screen.new("myFirstScreen"):setTitle("My first Frame!"):setTitleAlign("right")
|
||||||
# frame:setSize(int, int) -- changes the size (width, height)
|
````
|
||||||
# frame:showBar([bool]) -- shows/hides the bar on top where you will see the title if its active (no args = true)
|
**args:** string text - possible values: "left", "center", "right"<br>
|
||||||
# frame:isModifierActive(int or string) -- returns true if user is currently holding a key (following strings are possible: "shift","ctrl","alt"), int can be everything computercraft supports
|
**returns:** the frame object
|
||||||
# frame:show() -- shows the frame on the screen
|
|
||||||
# frame:hide() -- hides the frame
|
|
||||||
# frame:remove() -- removes the frame completly
|
|
||||||
# frame:getObject(string) - gets an created object (arg = id)
|
# frame:setPosition
|
||||||
# frame:removeObject(string) - removes the object with the id
|
Changes the position relative to its parent frame
|
||||||
# frame:addObject(object) -- you can add a object manually, normaly you shouldn't use this function, it gets called internally
|
````lua
|
||||||
# frame:drawObject() -- this draws the frame, you dont need that function, it gets called internally
|
local aScreen = screen.new("myFirstScreen"):setPosition(2,3)
|
||||||
# frame:mouseEvent(string,int,int,int) -- internal mouse event, better don't use it, i created mouse hooks for you
|
````
|
||||||
# frame:keyEvent(string,int) -- internal keyevent, better don't use it, i created key hooks for you
|
**args:** int x, int y<br>
|
||||||
# frame:changeZIndexOfObj(object, int) -- changes the z index of an object
|
**returns:** the frame object
|
||||||
# frame:setFocusedElement(object) -- changes the currently focused element
|
|
||||||
# frame:removeFocusedElement(object) -- removes the focus of the currently focused element
|
|
||||||
# frame:getFocusedElement() -- gets the currently focused element
|
|
||||||
# frame:getFocusEvent() -- event which gets fired when the frame gets the focus -- its more for internal usage
|
# frame:setBackground
|
||||||
# frame:setMoveable(bool) -- sets if the frame should be moveable or not (to move the frame you need to drag it on the top bar
|
Changes the background color from the frame
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen"):setBackground(colors.lightGray)
|
||||||
|
````
|
||||||
|
**args:** int color<br>
|
||||||
|
**returns:** the frame object
|
||||||
|
|
||||||
|
# frame:setForeground
|
||||||
|
Changes the text color from the frame
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen"):setForeground(colors.black)
|
||||||
|
````
|
||||||
|
**args:** int color<br>
|
||||||
|
**returns:** the frame object
|
||||||
|
|
||||||
|
# frame:setSize
|
||||||
|
Changes the frame size
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen"):setSize(15,5)
|
||||||
|
````
|
||||||
|
**args:** int width, int length<br>
|
||||||
|
**returns:** the frame object
|
||||||
|
|
||||||
|
# frame:showBar
|
||||||
|
shows/hides the bar on top where you will see the title if its active
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen"):showBar()
|
||||||
|
````
|
||||||
|
**args:** bool isVisible (no args = true)<br>
|
||||||
|
**returns:** the frame object<br>
|
||||||
|
|
||||||
|
# frame:isModifierActive
|
||||||
|
returns true if user is currently holding a key
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen"):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
|
||||||
|
aLabel:setText("shift is active yay")
|
||||||
|
else
|
||||||
|
aLabel:setText("shift is not active ohno")
|
||||||
|
end)
|
||||||
|
````
|
||||||
|
|
||||||
|
# frame:show
|
||||||
|
shows the frame on the screen
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen"):show()
|
||||||
|
````
|
||||||
|
**args:** -
|
||||||
|
**returns:** the frame object
|
||||||
|
# frame:hide
|
||||||
|
|
||||||
|
hides the frame
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen"):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()
|
||||||
|
end)
|
||||||
|
````
|
||||||
|
|
||||||
|
# frame:remove
|
||||||
|
removes the frame and its children objects completly
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen"):remove()
|
||||||
|
````
|
||||||
|
**args:** -<br>
|
||||||
|
**returns:** -<br>
|
||||||
|
|
||||||
|
# frame:getObject
|
||||||
|
returns a created object (arg = id)
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen")
|
||||||
|
aScreen:addButton("myFirstButton")
|
||||||
|
local aButton = aScreen:getObject("myFirstButton")
|
||||||
|
````
|
||||||
|
**args:** the id of the created object (has to be a child from the frame<br>
|
||||||
|
**returns:** object or nil
|
||||||
|
|
||||||
|
# frame:removeObject
|
||||||
|
removes the object with the id
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen")
|
||||||
|
aScreen:addButton("myFirstButton")
|
||||||
|
aScreen:removeObject("myFirstButton")
|
||||||
|
````
|
||||||
|
**args:** the id of the created object (has to be a child from the frame<br>
|
||||||
|
**returns:** object or nil
|
||||||
|
|
||||||
|
# frame:setFocusedElement
|
||||||
|
changes the currently focused element
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen")
|
||||||
|
local aButton = aScreen:addButton("myFirstButton")
|
||||||
|
aScreen:setFocusedElement(aButton)
|
||||||
|
````
|
||||||
|
**args:** the object you want to set as focus, has to be a children
|
||||||
|
**returns:** the frame object
|
||||||
|
# frame:removeFocusedElement
|
||||||
|
removes the focus of the currently focused element
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen")
|
||||||
|
local aButton = aScreen:addButton("myFirstButton")
|
||||||
|
aScreen:removeFocusedElement(aButton)
|
||||||
|
````
|
||||||
|
**args:** the object you want to set as focus, has to be a children
|
||||||
|
**returns:** the frame object
|
||||||
|
# frame:getFocusedElement
|
||||||
|
gets the currently focused element
|
||||||
|
````lua
|
||||||
|
local aScreen = screen.new("myFirstScreen")
|
||||||
|
local aButton = aScreen:addButton("myFirstButton")
|
||||||
|
local focusedObject = aScreen:getFocusedElement()
|
||||||
|
````
|
||||||
|
**args:** -<br>
|
||||||
|
**returns:** object<br>
|
||||||
|
|
||||||
|
# frame:setMoveable(bool)
|
||||||
|
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)
|
||||||
|
````
|
||||||
|
**args:** bool<br>
|
||||||
|
**returns:** object<br>
|
||||||
|
# frame:addObject
|
||||||
|
WIP
|
||||||
|
# frame:drawObject
|
||||||
|
WIP
|
||||||
|
# frame:mouseEvent
|
||||||
|
WIP
|
||||||
|
# frame:keyEvent
|
||||||
|
WIP
|
||||||
|
# frame:getFocusEvent
|
||||||
|
WIP
|
||||||
|
# frame:changeZIndexOfObj
|
||||||
|
WIP
|
||||||
|
|||||||
Reference in New Issue
Block a user