This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Obsidia's profile picture

Touchscreen in Computers themself

Started by Obsidia, 24 August 2015 - 01:59 PM
Obsidia #1
Posted 24 August 2015 - 03:59 PM
I was just wondering if it would be possible to use Lyqyds touchpoint API for buttons in computer itself?

If not:
What exactly do I need for buttons in the Computer itself? means as startup. I click on the pc and controll it with clicking where I want?
Is it just adding buttons and Event: mouse_click?

thanks for your help :)/>
KingofGamesYami #2
Posted 24 August 2015 - 04:26 PM
As stated in the touchpoint thread,


--# create a new instance of buttons on the top monitor (assumes API loaded as "touchpoint").
--# you can also not specify a side, and the touchpoint instance will use the current terminal and watch for mouse_click events (ComputerCraft 1.6+ only).
t = touchpoint.new("top")
Obsidia #3
Posted 24 August 2015 - 11:01 PM
As stated in the touchpoint thread,


--# create a new instance of buttons on the top monitor (assumes API loaded as "touchpoint").
--# you can also not specify a side, and the touchpoint instance will use the current terminal and watch for mouse_click events (ComputerCraft 1.6+ only).
t = touchpoint.new("top")


So what should the code look like?

like this?


os.loadAPI("touchpoint")
local t = touchpoint.new()  --- like this?
t:add("Button1", nil, 2, 2, 15, 4, colors.red, colors.lime)
t:draw()
while true do
  local event, button = t:handleEvents(os.pullEvent())
   if event == "mouse_click" then
	   if button == "Buttton1" the
	   rs.setOutput("right", true")
end
end
end

because.. like this it draws the button on the computerscreen but it doens exactly nothing if I click on it
KingofGamesYami #4
Posted 24 August 2015 - 11:04 PM
No, because the event is still "button_click". The API will internally wait for mouse_click events, instead of monitor_touch events on the specified monitor (because there isn't one).

Other than that minor detail, it should work perfectly.
Spoiler

os.loadAPI("touchpoint")
local t = touchpoint.new()  --- like this?
t:add("Button1", nil, 2, 2, 15, 4, colors.red, colors.lime)
t:draw()
while true do
  local event, button = t:handleEvents(os.pullEvent())
   if event == "button_click" then
           if button == "Buttton1" the
           rs.setOutput("right", true")
end
end
end
Obsidia #5
Posted 24 August 2015 - 11:16 PM
No, because the event is still "button_click". The API will internally wait for mouse_click events, instead of monitor_touch events on the specified monitor (because there isn't one).

Other than that minor detail, it should work perfectly.
Spoiler

os.loadAPI("touchpoint")
local t = touchpoint.new()  --- like this?
t:add("Button1", nil, 2, 2, 15, 4, colors.red, colors.lime)
t:draw()
while true do
  local event, button = t:handleEvents(os.pullEvent())
   if event == "button_click" then
		   if button == "Buttton1" the
		   rs.setOutput("right", true")
end
end
end

ah! works perfectly now! :)/> thanks mate! :)/>