ControlP5 button event

Dear all,
I wrote the following code:

// --8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-----

// ```
ControlP5 cp5;


final static String BUTTON_START="buttonStart";




 void initForm()
  {
    cp5 = new ControlP5(this);
    // cp5.setVisible(true);
   
    PImage[] imgs = {loadImage(PATH+PATH_BUTTON+BUTTON_START+RELEASED+".png"), loadImage(PATH+PATH_BUTTON+BUTTON_START+OVER+".png"), loadImage(PATH+PATH_BUTTON+BUTTON_START+PRESSED+".png")};
    cp5.addButton("start")
      .setValue(128)
      .setPosition(140, 300)
      .setImages(imgs)
      .updateSize()
      ;
      

  }


 public void start(int theValue) {
    println("a button event from buttonB: "+theValue);
    // exit();
    
  }

// --8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-----

// the draw() routine is empty

void draw()
{
}

It works but the function public void start(int theValue) is called even if the mouse is not clicked over the relative button.
Do you have any similar problem ? How do you fix it ?
Thank you very much for cooperation
regards

Please format the code by highlighting it and pressing the </> button in the text editor.

ok. I adjusted the post.
Thank you for suggestion

Is this all you code? I can’t see that you are checking for er the mouse to be pressed anywhere.
Which library are you using?

Dear “Eyeorelife”

you wroye:

Is this all you code? I can’t see that you are checking for er the mouse to be pressed anywhere.
Which library are you using?

No, of course, and the library that I’m using is ControlP5

ok, what i see with this:

import controlP5.*;

ControlP5 cp5;

void setup()
{
  cp5 = new ControlP5(this);

  //    PImage[] imgs = {loadImage(PATH+PATH_BUTTON+BUTTON_START+RELEASED+".png"), loadImage(PATH+PATH_BUTTON+BUTTON_START+OVER+".png"), loadImage(PATH+PATH_BUTTON+BUTTON_START+PRESSED+".png")};
  cp5.addButton("start")
    .setValue(128)
    .setPosition(10, 10)
    //      .setImages(imgs)
    .updateSize()
    .setLabel("START");
  ;
}

void draw() {
}

public void start(int theValue) {
  println("a button event from button START: "+theValue);
}

you are right, yes, at start i see already a “event line”

ControlP5 2.2.6 infos, comments, questions at processing GUI, controlP5
a button event from button START: 128

and add at every mouse click

//________________________________
if you want to use a other LIB?

import g4p_controls.*;

GButton button1;
import java.awt.Font;

void setup() {
  size(100, 100);
  button1 = new GButton(this, 10, 10, 80, 30);
  button1.setText("START");
  button1.setFont(new Font("Arial", Font.BOLD, 18));
  button1.setLocalColorScheme(0);
  
}

void draw() {
}

void handleButtonEvents(GButton button, GEvent event) {
  if (button == button1) { 
    println(" button1 clicked ");
  }
}