ControlP5 : isMouseOver test ?

sussus
edited April 2014 in Library Questions

Hi,

I am trying to reproduce this command ( http://forum.processing.org/one/topic/how-to-avoid-peasycam-rotations-when-using-controlp5-sliders.html ) to avoid rotation from control peasyCam when the mouse is over a controlP5 group.

My problem is I can't find a way to use isMouseOver() correctly as it always return true...

I reproduced a minimal version of my code :

import controlP5.*;

ControlP5 cp5;
Accordion panelControl;

void setup() {
  size(400, 400);
  initialiseGUI();
}

void draw() {
  background(0);
  if (panelControl.isMouseOver()) {
    println(frameCount, true);
  }
  else { 
    println(frameCount, false);
  }
}

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

  Group InitGroup = cp5.addGroup("Initialisation")
    .setBackgroundHeight(100)
      ;

  cp5.addSlider("slider")
    .setPosition(20, 20)
      .setSize(100, 10)
        .setRange(0, 50)
          .moveTo(InitGroup)
            ;

  panelControl = cp5.addAccordion("acc")
    .setWidth(220)
      .addItem(InitGroup)
        ;
}

what am i doing wrong ?

thanks for your time!

Answers

  • Answer ✓

    Hi, a quick fix is to change if (panelControl.isMouseOver()) { to if (cp5.isMouseOver()) {

    which returns true whenever the mouse is on top of a controller.

  • it works perfectly! many thanks!

Sign In or Register to comment.