17 posts
Posted 23 July 2017 - 12:27 PM
im trying to make buttons for my phone program to launch apps all i have for it is a border around the screen
how would i add buttons to launch programs to it?
66 posts
Location
Minecraft world
Posted 23 July 2017 - 01:15 PM
it depends if you want gui buttons, you could use many different ways of this but one way is to do ex: paintutils.drawFilledBox(1, 1, 10, 19, colors.gray)
and from there you want an mouse click detection and mouse click position
ex:
function click() --this function is for checking where and if clicked
event, button, x, y = os.pullEvent("mouse_click") --this will call the event with the variables button, x, y
if button == 1 then --if user click left click (2 is for right click and 3 is for middle click)
if x>=34 and x<= 45 and y == 3 then --check if x is more or equal to 34 and less or equal too 45 and Y is equal to 3 thats gonna be the area where the button is
shell.run("program to run here") --runs the program
end
end
end
Edited on 23 July 2017 - 11:17 AM
3057 posts
Location
United States of America
Posted 23 July 2017 - 01:16 PM
The easiest way would be to use a button API such as
touchpoint.
17 posts
Posted 23 July 2017 - 06:24 PM
both these replies confuse me xD
well Danels makes sense but the 4th line
3057 posts
Location
United States of America
Posted 23 July 2017 - 06:28 PM
If you have anything specific you'd like more information on, I'd be happy to oblige. Here's a
tutorial which may answer some of your questions.
66 posts
Location
Minecraft world
Posted 24 July 2017 - 09:21 AM
both these replies confuse me xD
well Danels makes sense but the 4th line
okay so the 4th line is to tell the program where it should accept the click/where the button area is
a good way to do this is too tell it first: if x is more or equal to example 34 and x is less or equal too 50 this will keep it in between 34 and 50 as x
picture: —–>34 between 50<—–
and lastly the Y it tells if the y is ex on line 3 then continue if all those is correct.
Note: you can do the same with Y as with x
I tried to do my best explaining just ask if you have any questions :)/>