docs update

Updated some docs stuff
This commit is contained in:
Robert Jelic
2022-10-09 12:05:30 +02:00
parent 44402b1d26
commit 1d3e2018ef
13 changed files with 228 additions and 7 deletions

View 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)
```

View 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)
```

View File

@@ -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

View 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)
```

View File

@@ -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)
```
```