docs update
Updated some docs stuff
This commit is contained in:
25
docs/objects/Object/onChar.md
Normal file
25
docs/objects/Object/onChar.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# onChar
|
||||
|
||||
`onChar(self, event, char)`<br>
|
||||
The computercraft event which triggers this method is `char`.
|
||||
|
||||
The char event always happens after the key event (just like in cc:tweaked)
|
||||
|
||||
Here is a example on how to add a onChar event to your frame:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
local subFrame = main:addFrame()
|
||||
:setPosition(3,3)
|
||||
:setSize(18,6)
|
||||
:hide()
|
||||
|
||||
function openSubFrame(self, event, char)
|
||||
if(char=="a")then
|
||||
subFrame:show()
|
||||
end
|
||||
end
|
||||
main:onChar(openSubFrame)
|
||||
```
|
||||
20
docs/objects/Object/onEvent.md
Normal file
20
docs/objects/Object/onEvent.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# onEvent
|
||||
|
||||
`onEvent(self, event, ...)`
|
||||
|
||||
This event gets called on any other event. Some examples: http_success, disk, modem_message, paste, peripheral, redstone,...
|
||||
|
||||
You can find a full list here: [CC:Tweaked](https://tweaked.cc/) (on the left sidebar)
|
||||
|
||||
Here is a example on how to add a onEvent event to your frame:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
main:onEvent(function(event, side, channel, replyChannel, message, distance)
|
||||
if(event=="modem_message")then
|
||||
basalt.debug("Mesage received: "..tostring(message))
|
||||
end
|
||||
end)
|
||||
```
|
||||
@@ -11,6 +11,7 @@ local main = basalt.createFrame()
|
||||
local subFrame = main:addFrame()
|
||||
:setPosition(3,3)
|
||||
:setSize(18,6)
|
||||
:hide()
|
||||
|
||||
function openSubFrame(self, event, key)
|
||||
if(key==keys.c)then
|
||||
|
||||
27
docs/objects/Object/onRelease.md
Normal file
27
docs/objects/Object/onRelease.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# onRelease
|
||||
`onRelease(self, event, button, x, y)`<br>
|
||||
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.
|
||||
|
||||
Here is a example on how to add a onRelease event to your button:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
local button = main:addButton()
|
||||
:setPosition(3,3)
|
||||
:setSize(12,3)
|
||||
:setText("Click")
|
||||
|
||||
function buttonOnClick(self, button, x, y)
|
||||
basalt.debug("Button got clicked!")
|
||||
end
|
||||
button:onClick(buttonOnClick)
|
||||
|
||||
function buttonOnRelease(self, button, x, y)
|
||||
basalt.debug("Button got released!")
|
||||
end
|
||||
button:onRelease(buttonOnRelease)
|
||||
```
|
||||
@@ -1,4 +1,5 @@
|
||||
# onResize
|
||||
|
||||
`onResize(self)`<br>
|
||||
This is a custom event which gets triggered as soon as the parent frame gets resized.
|
||||
|
||||
@@ -16,4 +17,4 @@ local function onButtonResize(self)
|
||||
end
|
||||
|
||||
aButton:onResize(onButtonResize)
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user