From 2960f79604dc9e7fcebed405c55df11c59d6f58d Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 27 Mar 2022 22:59:30 +0200 Subject: [PATCH] Updated Frames (& Screens) (markdown) --- Frames-(&-Screens).md | 215 +++++++++++++++++++++++++++++++++++------- 1 file changed, 182 insertions(+), 33 deletions(-) diff --git a/Frames-(&-Screens).md b/Frames-(&-Screens).md index 4a92f02..620d5cb 100644 --- a/Frames-(&-Screens).md +++ b/Frames-(&-Screens).md @@ -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
+**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
+**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
+**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 \ No newline at end of file + +# 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"
+**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
+**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
+**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
+**returns:** the frame object + +# frame:setSize +Changes the frame size +````lua +local aScreen = screen.new("myFirstScreen"):setSize(15,5) +```` +**args:** int width, int length
+**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)
+**returns:** the frame object
+ +# 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"
+**returns:** true or false if the user is holding the key down
+ +**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:** -
+**returns:** the frame object
+**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:** -
+**returns:** -
+ +# 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
+**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
+**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:** -
+**returns:** object
+ +# 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
+**returns:** object
+# frame:addObject + WIP +# frame:drawObject + WIP +# frame:mouseEvent + WIP +# frame:keyEvent + WIP +# frame:getFocusEvent + WIP +# frame:changeZIndexOfObj + WIP