Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Get id while hovering in scrollable list

$
0
0

Is there a way of getting the individual id of scrollable list in controlP5 while hovering? In the sketch below you get the id by clicking. Possible to get it by hovering?

import controlP5.*;
import java.util.*;

//String info;

ControlP5 cp5;

void setup() {
  size(400, 400);
  cp5 = new ControlP5(this);
  List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
  cp5.addScrollableList("dropdown")
    .setPosition(100, 100)
    .setSize(200, 100)
    .setBarHeight(20)
    .setItemHeight(20)
    .addItems(l)
    .setType(ScrollableList.LIST) // currently supported DROPDOWN and LIST
    .onMove(new CallbackListener() {
    public void controlEvent(CallbackEvent theEvent) {
      float value = theEvent.getController().getValue();
      println("the value is " + value);
    }
  }
  );
}

void draw() {
  background(240);
  // HOVER
  boolean over = cp5.get(ScrollableList.class, "dropdown").isMouseOver();
  // println("OVER " + over);
}

void dropdown(int n) {
  println("id:" + n);
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles