Jump to content




Buttons?


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

#1 Krul__Tepes

  • Members
  • 17 posts

Posted 23 July 2017 - 11:27 AM

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?

#2 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 23 July 2017 - 12: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 by danielsv03, 23 July 2017 - 12:17 PM.


#3 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 23 July 2017 - 12:16 PM

The easiest way would be to use a button API such as touchpoint.

#4 Krul__Tepes

  • Members
  • 17 posts

Posted 23 July 2017 - 05:24 PM

both these replies confuse me xD

well Danels makes sense but the 4th line

#5 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 23 July 2017 - 05: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.

#6 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 24 July 2017 - 08:21 AM

View PostKrul__Tepes, on 23 July 2017 - 05:24 PM, said:

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 :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users