# Create multiple buttons with different functions

**URL:** <https://discourse.processing.org/t/create-multiple-buttons-with-different-functions/2304>\
**Category:** Beginners\
**Created:** [August 2, 2018, 1:16pm UTC](https://discourse.processing.org/t/create-multiple-buttons-with-different-functions/2304 "2018-08-02T13:16:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haven](https://avatars.discourse-cdn.com/v4/letter/h/3ec8ea/32.png) [@Haven](https://discourse.processing.org/u/Haven)\
**Post date:** [August 2, 2018, 1:16pm UTC](https://discourse.processing.org/t/create-multiple-buttons-with-different-functions/2304/1 "2018-08-02T13:16:02Z")

</div>

Hi, I very new to processing and I have to do a project for my university.  
I can’t figure out how to build multiple buttons that each have a different function. The whole thing should be a quiz when it is ready. Total of 6 pages, start page with a how to, play and imprint button and the rest for the questions.  
Any help on how to set up the buttons would be great!

 ![button](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/1X/c7aeb4b48922740dd4b2215e15a34fe83eff7985.jpg)

---

<div class="post-metadata">

**Author:** ![erwrow](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erwrow](https://discourse.processing.org/u/erwrow)\
**Post date:** [August 2, 2018, 1:40pm UTC](https://discourse.processing.org/t/create-multiple-buttons-with-different-functions/2304/2 "2018-08-02T13:40:29Z")

</div>

you need to detect when a button from the [mouse](https://processing.org/reference/mouseClicked_.html) is pressed, if it was clicked on certain [x](https://processing.org/reference/mouseX.html) and [y](https://processing.org/reference/mouseY.html) position, then you execute one function or another. remember to constraint the position, example:

```auto
if(mouseClicked())
{
  if(mouseX >= 10 && mouseX <= 90)
  {
    FunctionA();
  }
}

```

the code above will execute the FunctionA() only if the mouse was clicked between the x positions of 10 and 90, you can extrapolate this to constraint the coordinates of the y axis

---

<div class="post-metadata">

**Author:** ![Haven](https://avatars.discourse-cdn.com/v4/letter/h/3ec8ea/32.png) [@Haven](https://discourse.processing.org/u/Haven)\
**Post date:** [August 2, 2018, 1:46pm UTC](https://discourse.processing.org/t/create-multiple-buttons-with-different-functions/2304/3 "2018-08-02T13:46:15Z")

</div>

Thank you very much for your fast answer! I will try this in a minute.
