Updated some formatting
Updated formatting for object
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## disable
|
## disable
|
||||||
|
|
||||||
Disables the object's event listeners
|
Disables the object's event listeners
|
||||||
|
|
||||||
This will disable the object. Which means it doesn't listen to any events anymore.
|
This will disable the object. Which means it doesn't listen to any events anymore.
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## enable
|
## enable
|
||||||
|
|
||||||
Enables the object's event listeners
|
Enables the object's event listeners
|
||||||
|
|
||||||
If the object's is disabled, it will stop listening to incoming events, this will reenable it.
|
If the object's is disabled, it will stop listening to incoming events, this will reenable it.
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## getAbsolutePosition
|
## getAbsolutePosition
|
||||||
|
|
||||||
Converts the relative coordinates into absolute coordinates
|
Converts the relative coordinates into absolute coordinates
|
||||||
#### Parameters:
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
1. `number|nil` x
|
1. `number|nil` x
|
||||||
2. `number|nil` y
|
2. `number|nil` y
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Creates a frame and a button and prints the button's absolute position to the debug console
|
* Creates a frame and a button and prints the button's absolute position to the debug console
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame():setPosition(3,3)
|
local mainFrame = basalt.createFrame():setPosition(3,3)
|
||||||
local aButton = mainFrame:addButton():setSize(8,1):setPosition(4,2)
|
local aButton = mainFrame:addButton():setSize(8,1):setPosition(4,2)
|
||||||
basalt.debug(aButton:getAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2
|
basalt.debug(aButton:getAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## getAnchorPosition
|
## getAnchorPosition
|
||||||
|
|
||||||
Converts the x and y coordinates into the anchor coordinates of the object
|
Converts the x and y coordinates into the anchor coordinates of the object
|
||||||
|
|
||||||
#### Parameters:
|
### Parameters
|
||||||
|
|
||||||
1. `number|nil` x
|
1. `number|nil` x
|
||||||
2. `number|nil` y, if nothing it uses the object's x, y
|
2. `number|nil` y, if nothing it uses the object's x, y
|
||||||
|
|
||||||
#### Returns:
|
#### Returns
|
||||||
|
|
||||||
1. `number` x
|
1. `number` x
|
||||||
2. `number` y
|
2. `number` y
|
||||||
|
|
||||||
#### Usage:
|
#### Usage
|
||||||
|
|
||||||
* Prints the anchor position to the debug console
|
* Prints the anchor position to the debug console
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame():setSize(15,15)
|
local mainFrame = basalt.createFrame():setSize(15,15)
|
||||||
local aButton = mainFrame:addButton()
|
local aButton = mainFrame:addButton()
|
||||||
@@ -18,4 +25,4 @@ local aButton = mainFrame:addButton()
|
|||||||
:setSize(8,1)
|
:setSize(8,1)
|
||||||
:setPosition(1,1)
|
:setPosition(1,1)
|
||||||
basalt.debug(aButton:getAnchorPosition()) -- returns 7,14 (framesize - own size) instead of 1,1
|
basalt.debug(aButton:getAnchorPosition()) -- returns 7,14 (framesize - own size) instead of 1,1
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## getBackground
|
## getBackground
|
||||||
|
|
||||||
Returns the current background color
|
Returns the current background color
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `number` color
|
1. `number` color
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## getForeground
|
## getForeground
|
||||||
|
|
||||||
Returns the current foreground color
|
Returns the current foreground color
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `number` color
|
1. `number` color
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## getName
|
## getName
|
||||||
|
|
||||||
Returns the given name of the object
|
Returns the given name of the object
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `string` name
|
1. `string` name
|
||||||
|
|
||||||
#### Usage:
|
#### Usage
|
||||||
|
|
||||||
* Prints name of object to debug window
|
* Prints name of object to debug window
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local main = basalt.createFrame()
|
local main = basalt.createFrame()
|
||||||
basalt.debug(main:getName()) -- returns the uuid
|
basalt.debug(main:getName()) -- returns the uuid
|
||||||
@@ -14,4 +20,4 @@ basalt.debug(main:getName()) -- returns the uuid
|
|||||||
```lua
|
```lua
|
||||||
local main = basalt.createFrame("myFirstMainFrame")
|
local main = basalt.createFrame("myFirstMainFrame")
|
||||||
basalt.debug(main:getName()) -- returns myFirstMainFrame
|
basalt.debug(main:getName()) -- returns myFirstMainFrame
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## getPosition
|
## getPosition
|
||||||
|
|
||||||
Returns the object's position
|
Returns the object's position
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `number` x
|
1. `number` x
|
||||||
2. `number` y
|
2. `number` y
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## getSize
|
## getSize
|
||||||
|
|
||||||
Returns the object's size
|
Returns the object's size
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `number` w
|
1. `number` w
|
||||||
2. `number` h
|
2. `number` h
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## getValue
|
## getValue
|
||||||
|
|
||||||
Returns the currently saved value
|
Returns the currently saved value
|
||||||
#### Returns:
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
1. `any` Object's value
|
1. `any` Object's value
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Prints the value of the checkbox to the debug console
|
* Prints the value of the checkbox to the debug console
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local aCheckbox = mainFrame:addCheckbox():setValue(true)
|
local aCheckbox = mainFrame:addCheckbox():setValue(true)
|
||||||
basalt.debug(aCheckbox:getValue()) -- returns true
|
basalt.debug(aCheckbox:getValue()) -- returns true
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## hide
|
## hide
|
||||||
|
|
||||||
Hides the object
|
Hides the object
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
#### Usage
|
||||||
|
|
||||||
* Hides a frame
|
* Hides a frame
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local button = mainFrame:addButton():setText("Close"):onClick(function() mainFrame:hide() end)
|
local button = mainFrame:addButton():setText("Close"):onClick(function() mainFrame:hide() end)
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<button visible="false" />
|
<button visible="false" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## isFocused
|
## isFocused
|
||||||
|
|
||||||
Returns if the object is currently the focused object of the parent frame
|
Returns if the object is currently the focused object of the parent frame
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `boolean` Whether the object is focused
|
1. `boolean` Whether the object is focused
|
||||||
|
|
||||||
#### Usage:
|
#### Usage
|
||||||
|
|
||||||
* Prints whether the button is focused to the debug console
|
* Prints whether the button is focused to the debug console
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local aButton = mainFrame:addButton()
|
local aButton = mainFrame:addButton()
|
||||||
basalt.debug(aButton:isFocused()) -- shows true or false as a debug message
|
basalt.debug(aButton:isFocused()) -- shows true or false as a debug message
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## isVisible
|
## isVisible
|
||||||
|
|
||||||
Returns if the object is currently visible
|
Returns if the object is currently visible
|
||||||
#### Returns:
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
1. `boolean`
|
1. `boolean`
|
||||||
|
|
||||||
#### Usage:
|
#### Usage
|
||||||
|
|
||||||
* Prints boolean visibility of object to debug console
|
* Prints boolean visibility of object to debug console
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local aButton = mainFrame:addButton():setSize(5,8)
|
local aButton = mainFrame:addButton():setSize(5,8)
|
||||||
basalt.debug(aButton:isVisible()) -- returns true
|
basalt.debug(aButton:isVisible()) -- returns true
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# onChange
|
# Object - Event
|
||||||
`onChange(self)`<br>
|
|
||||||
|
## onChange
|
||||||
|
|
||||||
|
`onChange(self)`
|
||||||
|
|
||||||
This is a custom event which gets triggered as soon as the function :setValue() is called. This function is also called by basalt, for example if you change the input, textfield or checkbox (or all the different types of lists) objects.
|
This is a custom event which gets triggered as soon as the function :setValue() is called. This function is also called by basalt, for example if you change the input, textfield or checkbox (or all the different types of lists) objects.
|
||||||
|
|
||||||
Here is a example on how to add a onChange event to your input, and also another example for your checkbox:
|
Here is a example on how to add a onChange event to your input, and also another example for your checkbox:
|
||||||
@@ -25,4 +29,4 @@ end
|
|||||||
|
|
||||||
aInput:onChange(checkInput)
|
aInput:onChange(checkInput)
|
||||||
aCheckbox:onChange(checkCheckbox)
|
aCheckbox:onChange(checkCheckbox)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
# onChar
|
# Object - Event
|
||||||
|
|
||||||
|
## onChar
|
||||||
|
|
||||||
|
`onChar(self, event, char)`
|
||||||
|
|
||||||
`onChar(self, event, char)`<br>
|
|
||||||
The computercraft event which triggers this method is `char`.
|
The computercraft event which triggers this method is `char`.
|
||||||
|
|
||||||
The char event always happens after the key event (just like in cc:tweaked)
|
The char event always happens after the key event (just like in cc:tweaked)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# onClick
|
# onClick
|
||||||
`onClick(self, event, button, x, y)`<br>
|
|
||||||
|
`onClick(self, event, button, x, y)`
|
||||||
|
|
||||||
The computercraft event which triggers this method is `mouse_click` and `monitor_touch`.
|
The computercraft event which triggers this method is `mouse_click` and `monitor_touch`.
|
||||||
|
|
||||||
Here is a example on how to add a onClick event to your button:
|
Here is a example on how to add a onClick event to your button:
|
||||||
@@ -20,6 +22,7 @@ button:onClick(buttonOnClick)
|
|||||||
```
|
```
|
||||||
|
|
||||||
Here is also a example on how you could create double clicks:
|
Here is also a example on how you could create double clicks:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local basalt = require("basalt")
|
local basalt = require("basalt")
|
||||||
local doubleClickMaxTime = 0.25 -- in seconds
|
local doubleClickMaxTime = 0.25 -- in seconds
|
||||||
@@ -44,4 +47,4 @@ end
|
|||||||
createDoubleClick(button, debugSomething) -- this is how you will create a double click.
|
createDoubleClick(button, debugSomething) -- this is how you will create a double click.
|
||||||
|
|
||||||
basalt.autoUpdate()
|
basalt.autoUpdate()
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# onClickUp
|
# Object - Event
|
||||||
`onClickUp(self, event, button, x, y)`<br>
|
|
||||||
|
## onClickUp
|
||||||
|
|
||||||
|
`onClickUp(self, event, button, x, y)`
|
||||||
|
|
||||||
The computercraft event which triggers this method is `mouse_up`.
|
The computercraft event which triggers this method is `mouse_up`.
|
||||||
|
|
||||||
Here is a example on how to add a onClickUp event to your button:
|
Here is a example on how to add a onClickUp event to your button:
|
||||||
@@ -22,4 +26,4 @@ function buttonOnRelease(self, button, x, y)
|
|||||||
basalt.debug("Button got released!")
|
basalt.debug("Button got released!")
|
||||||
end
|
end
|
||||||
button:onClickUp(buttonOnRelease)
|
button:onClickUp(buttonOnRelease)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
# onDrag
|
# Object - Event
|
||||||
`onDrag(self, event, button, x, y, xOffset, yOffset)`<br>
|
|
||||||
|
## onDrag
|
||||||
|
|
||||||
|
`onDrag(self, event, button, x, y, xOffset, yOffset)`
|
||||||
|
|
||||||
The computercraft event which triggers this method is `mouse_drag`.
|
The computercraft event which triggers this method is `mouse_drag`.
|
||||||
|
|
||||||
This is a example on how you would create a movable button:
|
This is a example on how you would create a movable button:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local basalt = require("basalt")
|
local basalt = require("basalt")
|
||||||
|
|
||||||
@@ -21,6 +26,7 @@ basalt.autoUpdate()
|
|||||||
```
|
```
|
||||||
|
|
||||||
Another example on how you could change the frame's offset by dragging around.
|
Another example on how you could change the frame's offset by dragging around.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local basalt = require("basalt")
|
local basalt = require("basalt")
|
||||||
|
|
||||||
@@ -43,6 +49,7 @@ basalt.autoUpdate()
|
|||||||
```
|
```
|
||||||
|
|
||||||
Also very interesting is a button where you are able to resize the frame just by dragging the button.
|
Also very interesting is a button where you are able to resize the frame just by dragging the button.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local basalt = require("basalt")
|
local basalt = require("basalt")
|
||||||
|
|
||||||
@@ -57,7 +64,7 @@ local dragButton = sub:addButton()
|
|||||||
:setSize(1,1)
|
:setSize(1,1)
|
||||||
:setText("/")
|
:setText("/")
|
||||||
:onDrag(function(self, button, x, y, xOffset, yOffset)
|
:onDrag(function(self, button, x, y, xOffset, yOffset)
|
||||||
sub:setSize(-xOffset, -yOffset, true)
|
sub:setSize(-xOffset, -yOffset, true)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
basalt.autoUpdate()
|
basalt.autoUpdate()
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# onEvent
|
# Object - Event
|
||||||
|
|
||||||
|
## onEvent
|
||||||
|
|
||||||
`onEvent(self, event, ...)`
|
`onEvent(self, event, ...)`
|
||||||
|
|
||||||
@@ -17,4 +19,4 @@ main:onEvent(function(event, side, channel, replyChannel, message, distance)
|
|||||||
basalt.debug("Mesage received: "..tostring(message))
|
basalt.debug("Mesage received: "..tostring(message))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# onGetFocus
|
# Object - Event
|
||||||
`onGetFocus(self)`<br>
|
|
||||||
|
## onGetFocus
|
||||||
|
|
||||||
|
`onGetFocus(self)`
|
||||||
|
|
||||||
This event gets triggered as soon as the object is the currently focused object.
|
This event gets triggered as soon as the object is the currently focused object.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
# onHover
|
# Object - Event
|
||||||
|
|
||||||
|
## onHover
|
||||||
|
|
||||||
|
`onHover(self, event, button, x, y)`
|
||||||
|
|
||||||
`onHover(self, event, button, x, y)`<br>
|
|
||||||
The computercraft event which triggers this method is `mouse_move` - only available in [CraftOS-PC](https://www.craftos-pc.cc).
|
The computercraft event which triggers this method is `mouse_move` - only available in [CraftOS-PC](https://www.craftos-pc.cc).
|
||||||
|
|
||||||
Here is a example on how to add a onHover event to your button:
|
Here is a example on how to add a onHover event to your button:
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# onKey
|
# Object - Event
|
||||||
`onKey(self, event, key)`<br>
|
|
||||||
|
## onKey
|
||||||
|
|
||||||
|
`onKey(self, event, key)`
|
||||||
|
|
||||||
The computercraft event which triggers this method is `key` and `char`.
|
The computercraft event which triggers this method is `key` and `char`.
|
||||||
|
|
||||||
Here is a example on how to add a onKey event to your frame:
|
Here is a example on how to add a onKey event to your frame:
|
||||||
@@ -19,4 +23,4 @@ function openSubFrame(self, event, key)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
main:onKey(openSubFrame)
|
main:onKey(openSubFrame)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# onKeyUp
|
# Object - Event
|
||||||
`onKeyUp(self, event, key)`<br>
|
|
||||||
|
## onKeyUp
|
||||||
|
|
||||||
|
`onKeyUp(self, event, key)`
|
||||||
|
|
||||||
The computercraft event which triggers this method is `key_up`.
|
The computercraft event which triggers this method is `key_up`.
|
||||||
|
|
||||||
Here is a example on how to add a onKeyUp event to your frame:
|
Here is a example on how to add a onKeyUp event to your frame:
|
||||||
@@ -18,4 +22,4 @@ function openSubFrame(self, event, key)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
main:onKeyUp(openSubFrame)
|
main:onKeyUp(openSubFrame)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
# onLeave
|
# Object - Event
|
||||||
|
|
||||||
|
## onLeave
|
||||||
|
|
||||||
|
`onLeave(self, event, button, x, y)`
|
||||||
|
|
||||||
`onLeave(self, event, button, x, y)`<br>
|
|
||||||
The computercraft event which triggers this method is `mouse_move` - only available in [CraftOS-PC](https://www.craftos-pc.cc).
|
The computercraft event which triggers this method is `mouse_move` - only available in [CraftOS-PC](https://www.craftos-pc.cc).
|
||||||
|
|
||||||
Here is a example on how to add a onLeave event to your button:
|
Here is a example on how to add a onLeave event to your button:
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# onLoseFocus
|
# Object - Event
|
||||||
`onLoseFocus(self)`<br>
|
|
||||||
|
## onLoseFocus
|
||||||
|
|
||||||
|
`onLoseFocus(self)`
|
||||||
|
|
||||||
This event gets triggered as soon as the object loses its focus.
|
This event gets triggered as soon as the object loses its focus.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -13,4 +17,4 @@ local aButton = main:addButton()
|
|||||||
basalt.debug("Please come back...")
|
basalt.debug("Please come back...")
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# onRelease
|
# Object - Event
|
||||||
`onRelease(self, event, button, x, y)`<br>
|
|
||||||
|
## onRelease
|
||||||
|
|
||||||
|
`onRelease(self, event, button, x, y)`
|
||||||
|
|
||||||
The computercraft event which triggers this method is `mouse_up`.
|
The computercraft event which triggers this method is `mouse_up`.
|
||||||
|
|
||||||
The difference between onRelease and :onClickUp is that :onRelease is called even when the mouse is no longer over the object, while :onClickUp is only called when the mouse is over the object.
|
The difference between onRelease and :onClickUp is that :onRelease is called even when the mouse is no longer over the object, while :onClickUp is only called when the mouse is over the object.
|
||||||
@@ -24,4 +28,4 @@ function buttonOnRelease(self, button, x, y)
|
|||||||
basalt.debug("Button got released!")
|
basalt.debug("Button got released!")
|
||||||
end
|
end
|
||||||
button:onRelease(buttonOnRelease)
|
button:onRelease(buttonOnRelease)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Object - Event
|
||||||
|
|
||||||
|
## onReposition
|
||||||
|
|
||||||
|
`onReposition(self)`
|
||||||
|
|
||||||
|
This is a custom event which gets triggered as soon as the object gets repositioned (for example by dynamic value).
|
||||||
|
|
||||||
|
Here is a example on how to add a onReposition event to your button:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local basalt = require("basalt")
|
||||||
|
|
||||||
|
local main = basalt.createFrame()
|
||||||
|
local aButton = main:addButton():setPosition(3,3)
|
||||||
|
|
||||||
|
local function onButtonReposition(self)
|
||||||
|
self:setSize(self:getWidth() - self:getX(), 3)
|
||||||
|
end
|
||||||
|
|
||||||
|
aButton:onReposition(onButtonReposition)
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
# onResize
|
# Object - Event
|
||||||
|
|
||||||
|
## onResize
|
||||||
|
|
||||||
|
`onResize(self)`
|
||||||
|
|
||||||
`onResize(self)`<br>
|
|
||||||
This is a custom event which gets triggered as soon as the parent frame gets resized.
|
This is a custom event which gets triggered as soon as the parent frame gets resized.
|
||||||
|
|
||||||
Here is a example on how to add a onResize event to your button:
|
Here is a example on how to add a onResize event to your button:
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# onScroll
|
# Object - Event
|
||||||
`onScroll(self, event, direction, x, y)`<br>
|
|
||||||
|
## onScroll
|
||||||
|
|
||||||
|
`onScroll(self, event, direction, x, y)`
|
||||||
|
|
||||||
The computercraft event which triggers this method is `mouse_scroll`.
|
The computercraft event which triggers this method is `mouse_scroll`.
|
||||||
|
|
||||||
Here is a example on how to add a onScroll event to your button:
|
Here is a example on how to add a onScroll event to your button:
|
||||||
@@ -17,4 +21,4 @@ function buttonOnScroll(self, direction, x, y)
|
|||||||
basalt.debug("Someone scrolls on me!")
|
basalt.debug("Someone scrolls on me!")
|
||||||
end
|
end
|
||||||
button:onScroll(buttonOnScroll)
|
button:onScroll(buttonOnScroll)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## remove
|
## remove
|
||||||
|
|
||||||
Removes the object from it's parent frame. This won't 'destroy' the object, It will continue to exist as long as you still have pointers to it.
|
Removes the object from it's parent frame. This won't 'destroy' the object, It will continue to exist as long as you still have pointers to it.
|
||||||
|
|
||||||
Here is a example on how a button will be fully removed from the memory:
|
Here is a example on how a button will be fully removed from the memory:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local main = basalt.createFrame()
|
local main = basalt.createFrame()
|
||||||
local button = main:addButton():setPosition(2,2):setText("Close")
|
local button = main:addButton():setPosition(2,2):setText("Close")
|
||||||
|
|
||||||
button:remove()
|
button:remove()
|
||||||
button = nil
|
button = nil
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setAnchor
|
## setAnchor
|
||||||
|
|
||||||
Sets the anchor of the object
|
Sets the anchor of the object
|
||||||
|
|
||||||
#### Parameters:
|
### Parameters
|
||||||
|
|
||||||
1. `string` Anchor sides `("topLeft" "top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "center")`
|
1. `string` Anchor sides `("topLeft" "top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "center")`
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Sets the button to have an anchor of `bottomRight`
|
* Sets the button to have an anchor of `bottomRight`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame():show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aButton = mainFrame:addButton()
|
local aButton = mainFrame:addButton()
|
||||||
@@ -16,6 +23,7 @@ local aButton = mainFrame:addButton()
|
|||||||
:setSize(8,1)
|
:setSize(8,1)
|
||||||
:setPosition(-8,1)
|
:setPosition(-8,1)
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<button anchor="bottomRight" />
|
<button anchor="bottomRight" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,16 +1,27 @@
|
|||||||
## setBackground
|
# Object
|
||||||
Changes the object background color, if you set the value to false the background wont be visible. For example you could see trough a frame.
|
|
||||||
#### Parameters:
|
## setBackground
|
||||||
1. `number|color` Background color
|
|
||||||
|
Changes the object background color, if you set the value to false the background wont be visible. For example you could see trough a frame.
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
1. `number|color` Background color
|
||||||
|
1. `char` background symbol you want to draw (optional)
|
||||||
|
1. `number|color` Background symbol color (optional)
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
#### Returns:
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
* Creates a frame, and sets its background color to `colors.gray`
|
|
||||||
|
* Creates a frame, and sets its background color to `colors.gray`, also sets a background symbol with color black.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame():setBackground(colors.gray)
|
local mainFrame = basalt.createFrame():setBackground(colors.gray, "#", colors.black)
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<button bg="gray" />
|
<button bg="gray" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setBorder
|
## setBorder
|
||||||
Sets the border of that objects, if false the border will be removed<br>
|
|
||||||
|
Sets the border of that objects, if false the border will be removed
|
||||||
|
|
||||||
Default: false
|
Default: false
|
||||||
|
|
||||||
#### Parameters:
|
### Parameters
|
||||||
|
|
||||||
1. `number|color` Border color
|
1. `number|color` Border color
|
||||||
2. `string` optional - sides. If you don't set sides, all 4 sides will have a border
|
2. `string` optional - sides. If you don't set sides, all 4 sides will have a border
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Sets the border to green and shows it:
|
* Sets the border to green and shows it:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local subFrame = mainFrame:addFrame()
|
local subFrame = mainFrame:addFrame()
|
||||||
@@ -18,6 +26,7 @@ local subFrame = mainFrame:addFrame()
|
|||||||
:setSize(18,6)
|
:setSize(18,6)
|
||||||
:setBorder(colors.green, "left", "right", "bottom")
|
:setBorder(colors.green, "left", "right", "bottom")
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<frame width="18" height="6" borderColor="green" movable="true" />
|
<frame width="18" height="6" borderColor="green" movable="true" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
## setFocus
|
# Object
|
||||||
|
|
||||||
|
## setFocus
|
||||||
|
|
||||||
Sets the object to be the focused object.
|
Sets the object to be the focused object.
|
||||||
If you click on an object, it's normally automatically the focused object. For example, if you call :show() on a frame, and you want this particular frame to be in
|
If you click on an object, it's normally automatically the focused object. For example, if you call :show() on a frame, and you want this particular frame to be in
|
||||||
the foreground, you should also use :setFocus()
|
the foreground, you should also use :setFocus()
|
||||||
#### Returns:
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Sets the button to the focused object
|
* Sets the button to the focused object
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local aButton = mainFrame:addButton():setFocus()
|
local aButton = mainFrame:addButton():setFocus()
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setForeground
|
## setForeground
|
||||||
|
|
||||||
Changes the object text color
|
Changes the object text color
|
||||||
#### Parameters:
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
1. `number|color` Foreground color
|
1. `number|color` Foreground color
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Creates a frame, and sets its foreground color to `colors.green`
|
* Creates a frame, and sets its foreground color to `colors.green`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame():setForeground(colors.green)
|
local mainFrame = basalt.createFrame():setForeground(colors.green)
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<button fg="green" />
|
<button fg="green" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setParent
|
## setParent
|
||||||
|
|
||||||
Sets the parent frame of the object
|
Sets the parent frame of the object
|
||||||
#### Parameters:
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
1. `frame` The to-be parent frame
|
1. `frame` The to-be parent frame
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Sets the parent frame of the random frame, adding it to the main frame when the button is clicked"
|
* Sets the parent frame of the random frame, adding it to the main frame when the button is clicked"
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local aRandomFrame = basalt.createFrame()
|
local aRandomFrame = basalt.createFrame()
|
||||||
@@ -16,4 +24,4 @@ local aButton = mainFrame:addButton():onClick(
|
|||||||
aRandomFrame:setParent(mainFrame)
|
aRandomFrame:setParent(mainFrame)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,28 +1,39 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setPosition
|
## setPosition
|
||||||
|
|
||||||
Changes the position relative to its parent frame
|
Changes the position relative to its parent frame
|
||||||
#### Parameters:
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
1. `number|string` x coordinate as number or dynamicvalue as string
|
1. `number|string` x coordinate as number or dynamicvalue as string
|
||||||
2. `number|string` y coordinate as number or dynamicvalue as string
|
2. `number|string` y coordinate as number or dynamicvalue as string
|
||||||
3. `boolean` Whether it will add/remove to the current coordinates instead of setting them
|
3. `boolean` Whether it will add/remove to the current coordinates instead of setting them
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Sets the Buttons position to an x coordinate of 2 with a y coordinate of 3
|
* Sets the Buttons position to an x coordinate of 2 with a y coordinate of 3
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
mainFrame:addButton():setPosition(2,3)
|
mainFrame:addButton():setPosition(2,3)
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<button x="2" y="3" />
|
<button x="2" y="3" />
|
||||||
```
|
```
|
||||||
|
|
||||||
if you prefer to use dynamic values:
|
if you prefer to use dynamic values:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
mainFrame:addButton():setPosition("parent.w * 0.5", 23)
|
mainFrame:addButton():setPosition("parent.w * 0.5", 23)
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<button x="parent.w * 0.5" y="3" />
|
<button x="parent.w * 0.5" y="3" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setShadow
|
## setShadow
|
||||||
|
|
||||||
Sets the shadow color - default: false
|
Sets the shadow color - default: false
|
||||||
|
|
||||||
#### Parameters:
|
### Parameters
|
||||||
|
|
||||||
1. `number|color` Shadow color
|
1. `number|color` Shadow color
|
||||||
|
|
||||||
#### Returns:
|
#### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
#### Usage
|
||||||
|
|
||||||
* Sets the shadow to green and shows it:
|
* Sets the shadow to green and shows it:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local subFrame = mainFrame:addFrame()
|
local subFrame = mainFrame:addFrame()
|
||||||
@@ -16,7 +23,9 @@ local subFrame = mainFrame:addFrame()
|
|||||||
:setSize(18,6)
|
:setSize(18,6)
|
||||||
:setShadow(colors.green)
|
:setShadow(colors.green)
|
||||||
```
|
```
|
||||||
Or:
|
|
||||||
|
Or:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<frame width="18" height="6" shadowColor="green" movable="true" />
|
<frame width="18" height="6" shadowColor="green" movable="true" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,18 +1,27 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setSize
|
## setSize
|
||||||
|
|
||||||
Changes the object size
|
Changes the object size
|
||||||
#### Parameters:
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
1. `number|string` width as number or dynamicvalue as string
|
1. `number|string` width as number or dynamicvalue as string
|
||||||
2. `number|string` height as number or dynamicvalue as string
|
2. `number|string` height as number or dynamicvalue as string
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Sets the frame to have a width of 15 and a height of 12
|
* Sets the frame to have a width of 15 and a height of 12
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local subFrame = mainFrame:addFrame():setSize(15,12)
|
local subFrame = mainFrame:addFrame():setSize(15,12)
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<frame width="15" height="12" />
|
<frame width="15" height="12" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,17 +1,26 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setValue
|
## setValue
|
||||||
|
|
||||||
Sets the value of that object (input, label, checkbox, textfield, scrollbar,...)
|
Sets the value of that object (input, label, checkbox, textfield, scrollbar,...)
|
||||||
#### Parameters:
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
1. `any` Value to set the object to
|
1. `any` Value to set the object to
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Creates a checkbox and ticks it
|
* Creates a checkbox and ticks it
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local aCheckbox = mainFrame:addCheckbox():setValue(true)
|
local aCheckbox = mainFrame:addCheckbox():setValue(true)
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<checkbox value="true" />
|
<checkbox value="true" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,19 +1,28 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## setZIndex
|
## setZIndex
|
||||||
|
|
||||||
Sets the z-index. Higher value means higher draw/event priority. You can also add multiple objects to the same z-index, if so the last added object will have the highest priority.
|
Sets the z-index. Higher value means higher draw/event priority. You can also add multiple objects to the same z-index, if so the last added object will have the highest priority.
|
||||||
#### Parameters:
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
1. `number` z-index
|
1. `number` z-index
|
||||||
|
|
||||||
#### Returns:
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Sets the buttons z-index to `1` and the labels z-index to `2`
|
* Sets the buttons z-index to `1` and the labels z-index to `2`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local aButton = mainFrame:addButton():setZIndex(1):setPosition(2,2)
|
local aButton = mainFrame:addButton():setZIndex(1):setPosition(2,2)
|
||||||
local aLabel = mainFrame:addButton():setZIndex(2):setPosition(2,2):setText("I am a label!")
|
local aLabel = mainFrame:addButton():setZIndex(2):setPosition(2,2):setText("I am a label!")
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<button x="2" y="2" zIndex="1" />
|
<button x="2" y="2" zIndex="1" />
|
||||||
<label x="2" y="2" text="I am a label!" zIndex="2" />
|
<label x="2" y="2" text="I am a label!" zIndex="2" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
|
# Object
|
||||||
|
|
||||||
## show
|
## show
|
||||||
|
|
||||||
Shows the object (only if the parent frame is already visible)
|
Shows the object (only if the parent frame is already visible)
|
||||||
#### Returns:
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
|
|
||||||
#### Usage:
|
### Usage
|
||||||
|
|
||||||
* Shows a frame
|
* Shows a frame
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame()
|
local mainFrame = basalt.createFrame()
|
||||||
local button = mainFrame:addButton()
|
local button = mainFrame:addButton()
|
||||||
button:show()
|
button:show()
|
||||||
```
|
```
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<button visible="true" />
|
<button visible="true" />
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user