Jump to content




how do i make clickable buttons in functions?


  • You cannot reply to this topic
5 replies to this topic

#1 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 03 July 2015 - 11:52 AM

i want to make a function so i can add it into a program to make anything clickable, possibly using coroutines.

i tried coroutines one time, but i never got the hang of it. maybe someone who knows it can help?

so i would do something like
function clickable(text,funct)
--function
end
function funct1()
--random things here
end
function funct2()
--random things here
end
clickable("text1",funct1())
clickable("text2",funct2())
and that would do stuff .-.

#2 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 03 July 2015 - 12:41 PM

look at someones buttion API and either uses their's or use it to teach you how to make your own

Lyqyds touhpoint is a popular one.

Edited by Lupus590, 03 July 2015 - 12:42 PM.


#3 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 03 July 2015 - 01:13 PM

Nah don't use API's :P Make your own :P Check out my link to making touch screen buttons:
http://www.computerc...-on-a-terminal/

#4 Lewisk3

  • Members
  • 150 posts

Posted 20 July 2015 - 06:01 PM

i like doing a button table system like so,

local buttons = {
	   {name="Button Name",w=<width>,h=<height>,click = function()    
                 -- when button is clicked this code will run --
				  os.reboot()
		end}
}

function update()
		   a = {os.pullEvent()}
	
		if(a[1] == "mouse_click")then
			 for i = 1, #buttons do
				 -- insert updating code here --
			 end
		end
end

function draw()
		  for i = 1, #buttons do
			  -- insert drawing code here --
		 end
end

function dabigloop()
         draw()
	while true do
		  update()
          --]] dont put draw here because it will cause flickering instead handle screen refresh in the update method [[--
	end
end

Edited by Redxone, 20 July 2015 - 06:03 PM.


#5 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 20 July 2015 - 10:28 PM

View PostDannySMc, on 03 July 2015 - 01:13 PM, said:

Nah don't use API's :P Make your own :P Check out my link to making touch screen buttons:
http://www.computerc...-on-a-terminal/

There is no need for making a "low level" (actually not that low level) API/script if others made it for you already. You don't have to reinvent the wheel.

#6 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 20 July 2015 - 10:45 PM

View PostH4X0RZ, on 20 July 2015 - 10:28 PM, said:

View PostDannySMc, on 03 July 2015 - 01:13 PM, said:

Nah don't use API's :P Make your own :P Check out my link to making touch screen buttons:
http://www.computerc...-on-a-terminal/

There is no need for making a "low level" (actually not that low level) API/script if others made it for you already. You don't have to reinvent the wheel.

No there may not, but I have never been keen on using others API's and you are best learning it from step 1, instead of using APIs, thus giving you a better understanding of what is going on. otherwise you may not know how it all works.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users