Log In  


I am having trouble understanding how to create a clickable button that can be clicked with a mouse. Although I've looked at some posts about it, I'm still confused. Could someone please explain to me a clear explanation?

1


1

Cart #tasubafozu-0 | 2024-06-28 | Embed ▽ | License: CC4-BY-NC-SA
1

I'm not sure if my explanation makes sense, but using a table like an object-oriented class will save you time and effort.
This "pseudo-class" remembers the button positions and text, and has an update "method" that reacts when the mouse enters or the button is pressed.
In _init() I created two buttons in a new table using the "pseudo-class".
In _draw() I call the update method for each button.

Give it a try :)


1

You should look into the gui library that comes built into picotron!


1

Since I cannot judge your programming proficiency, I will give you a brief description.

If you have difficulty with the objective, try to break down what you are creating.

  • Obtain mouse input.
    • Use mouse() to get the x/y of the coordinates, and the state of the button.
  • Determine that you clicked.
    • use print() to check the button status
  • Create the area of the button.
    • For the rectangle used in picotron, it may be useful to have variables for the Start x/y and End x/y coordinates to draw and determine the button's state.
  • Draw the button.
    • Use the rect() function.

If you can create these one by one, you are pretty close to what you want.

https://www.lexaloffle.com/dl/docs/picotron_manual.html
Check the manual for details on how to use the functions.
Since picotron is still in alpha version, you may encounter specification changes or unstable situations.
Nevertheless, I am enjoying this world.


1

Thank you everyone. I am now closer to understanding Picotron.



[Please log in to post a comment]