Pyroxenium / Basalt

A UI Framework for CC:Tweaked
MIT License
194 stars 38 forks source link

Bug: Button OnClick not detecting clicks #103

Closed Tarkz closed 10 months ago

Tarkz commented 10 months ago

I've installed basalt and set up my first program following the tutorial. I've set up a button by using

local btnGate = controlfram :addButton() :setPosition(2,2) :setText("[ OPEN ]") :setBackground(colors.yellow)

I originally had the onclick set up as part of the call chain, but have movied it to be it's own section

btnGate:onClick(function(self,event,button,x,y) basalt.debug("CLICK EVENT") if (event == "mouse_click") and (button == 1) then basalt.debug("CLICKED") open("gate") --My function call for my gates end end)

after this I have the basalt.autoUpdate() call. The program starts up, and I can drag the movableframe around like it's supposed to, but clicking a button never does anything. And the debug events are never called. I'm not sure why.

Checklist

[ X] I am running the latest version.

Erb3 commented 10 months ago

It appears that basalt.debug is a bit broken. However, the code below works on my machine:

local basalt = require("basalt")
local main = basalt.createFrame()

local btnGate = main
  :addButton()
  :setPosition(2,2)
  :setText("[ Shutdown ]")
  :setBackground(colors.yellow)
  :onClick(function(self, event, button, x, y)
    os.shutdown()
  end)

basalt.autoUpdate()

Be sure to update os.shutdown() with something more useful, like your function open("gate")

Tarkz commented 10 months ago

It appears that basalt.debug is a bit broken. However, the code below works on my machine:

local basalt = require("basalt")
local main = basalt.createFrame()

local btnGate = main
  :addButton()
  :setPosition(2,2)
  :setText("[ Shutdown ]")
  :setBackground(colors.yellow)
  :onClick(function(self, event, button, x, y)
    os.shutdown()
  end)

basalt.autoUpdate()

Be sure to update os.shutdown() with something more useful, like your function open("gate")

I took out the debugs and tried it with the os.shutdown() and confirmed that worked. I put back in my open("gate") function and it seems to run the function, but skips over the rednet broadcast call.

rednet.broadcast("open","Gatekeeper")

is there something else I have to do to have basalt broadcast rednet commands?

Tarkz commented 10 months ago

It appears that basalt.debug is a bit broken. However, the code below works on my machine:

local basalt = require("basalt")
local main = basalt.createFrame()

local btnGate = main
  :addButton()
  :setPosition(2,2)
  :setText("[ Shutdown ]")
  :setBackground(colors.yellow)
  :onClick(function(self, event, button, x, y)
    os.shutdown()
  end)

basalt.autoUpdate()

Be sure to update os.shutdown() with something more useful, like your function open("gate")

I took out the debugs and tried it with the os.shutdown() and confirmed that worked. I put back in my open("gate") function and it seems to run the function, but skips over the rednet broadcast call.

rednet.broadcast("open","Gatekeeper")

is there something else I have to do to have basalt broadcast rednet commands?

In case it helps the open("gate") function is:

function open(sTarget) if sTarget == "gate" then rednet.broadcast("open", "Gatekeeper") end end

A really simple function for now. And I have the rednet.broadcast() call working when I use a pocket computer with the basic lua terminal as well as other CC based programs.

Tarkz commented 10 months ago

I did get a redstone command to work from my Advanced Pocket Computer using the Basalt UI. So I just have to assume the issue is with my program on the Advanced Computer controlling the gate. Thank you for the help with the basalt.debug() earlier.