Updated Frames (& Screens) (markdown)
@@ -7,15 +7,15 @@ this function creates a new screen
|
||||
````lua
|
||||
local firstScreen = screen.new("myFirstScreen")
|
||||
````
|
||||
par: string identifaction id. if you create 2 frames with the same id, the second one will return nil
|
||||
returns a frame object
|
||||
**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
|
||||
# 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
|
||||
frame:addFrame("myFirstFrame")
|
||||
````
|
||||
par: string identifaction id. if you create 2 frames with the same id, the second one will return nil
|
||||
returns a frame object
|
||||
**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
|
||||
Example:
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
@@ -24,41 +24,190 @@ local aFrame = aScreen:addFrame("myFirstFrame")
|
||||
# frame:setTitle
|
||||
Changes the title from a frame or screen
|
||||
````lua
|
||||
frame:setTitle("My first Frame!)
|
||||
frame:setTitle("My first Frame!")
|
||||
````
|
||||
par: string text
|
||||
returns the frame object
|
||||
**args:** string text<br>
|
||||
**returns:** the frame object
|
||||
Example:
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen")
|
||||
local aFrame = aScreen:addFrame("myFirstFrame")
|
||||
aFrame:setTitle("My first Frame!)
|
||||
aFrame:setTitle("My first Frame!")
|
||||
````
|
||||
or:
|
||||
````lua
|
||||
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:setPosition(int, int) -- changes the position relative to its parent frame
|
||||
# frame:setBackground(int) -- changes the background color
|
||||
# frame:setForeground(int) -- changes the text color
|
||||
# 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)
|
||||
# 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
|
||||
# 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:removeObject(string) - removes the object with the id
|
||||
# frame:addObject(object) -- you can add a object manually, normaly you shouldn't use this function, it gets called internally
|
||||
# frame:drawObject() -- this draws the frame, you dont need that function, it gets called internally
|
||||
# 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
|
||||
# frame:changeZIndexOfObj(object, int) -- changes the z index of an 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:setMoveable(bool) -- sets if the frame should be moveable or not (to move the frame you need to drag it on the top bar
|
||||
|
||||
# frame:setTitleAlign
|
||||
Sets the title alignment
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setTitle("My first Frame!"):setTitleAlign("right")
|
||||
````
|
||||
**args:** string text - possible values: "left", "center", "right"<br>
|
||||
**returns:** the frame object
|
||||
|
||||
|
||||
|
||||
# frame:setPosition
|
||||
Changes the position relative to its parent frame
|
||||
````lua
|
||||
local aScreen = screen.new("myFirstScreen"):setPosition(2,3)
|
||||
````
|
||||
**args:** int x, int y<br>
|
||||
**returns:** the frame object
|
||||
|
||||
|
||||
|
||||
# frame:setBackground
|
||||
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