Question about sliders in controlP5 library (in Android mode)

I’ve just started using the G4P library to develop an app in Android mode. It seems that you have to touch a slider first to give it focus, before it actually reacts. The problem is that if you have more than one slider, touching one slider affects the slider which previously had focus. Here’s my sketch (just two sliders so far):

import controlP5.*;

ControlP5 cp5;

int colBkgd = color(0,100,50);

void setup() {
  fullScreen();
  orientation(PORTRAIT);
  noStroke();
  println("displayDensity :",displayDensity);
  println("width :",width);
  println("height :",height);
  PFont font = createFont("arial",24*displayDensity);
  cp5 = new ControlP5(this);
  cp5.addSlider("Note")
     .setPosition(int(width*0.1),int(height*0.05))
     .setSize(int(width*0.3),int(height*0.05))
     .setRange(0,127)
     .setNumberOfTickMarks(5)
     .snapToTickMarks(false)
     ;
  cp5.getController("Note")
     .getCaptionLabel()
     .setFont(font)
     .setPaddingX(25)
     ;
  cp5.getController("Note")
     .getValueLabel()
     .setFont(font)
     .setPaddingX(10)
     ;
  cp5.addSlider("Gain")
     .setPosition(int(width*0.1),int(height*0.15))
     .setSize(int(width*0.3),int(height*0.05))
     .setRange(0.0,1.0)
     .setNumberOfTickMarks(6)
     .snapToTickMarks(false)
     ;
  cp5.getController("Gain")
     .getCaptionLabel()
     .setFont(font)
     .setPaddingX(25)
     ;
  cp5.getController("Gain")
     .getValueLabel()
     .setFont(font)
     .setPaddingX(10)
     ;
}

void draw() {
  background(colBkgd);
}

Am I doing something wrong? Is this expected behaviour or a bug? This doesn’t happen if I run it in Java mode on the computer. Clicking on the second slider with the mouse immediately gives it focus. (I’ve given up trying to use the Android mode emulator, it takes longer than running the sketch on the actual device and always times out waiting for the “emulator to become available”.)

Thanks.

Clarification needed: Post says G4P library but demo shows controlP5 sliders?

The code you show is not G4P but controlP5. I have changed the discussion title to reflect this.

FYI G4P is not suitable for Android.

1 Like

In android you have to tap on it first to give it focus, then make the adjustment. Note that in your demo the blue slider bar changes color when it has focus.

1 Like

Sorry, my mistake.

Yes, I realize you have to tap on it to give it focus. But the problem is, tapping on the second slider also moves the first slider that previously had focus. Does the library work in Android mode?

Hi

It’s working but when you touching slider remain activated even touch any part of screen make the slider move

Controlp5 not good for Android even you can run sketch

I managed to find the Github repository (Issues · sojamo/controlp5 · GitHub), after a bit of hunting. The link to “Source Code” on the library web takes you to the old Google Code archive.

Anyway, on the Github repository, there are 87 open issues, none of which have been assigned to anyone. Does this mean the library is no longer being supported?

Hi

To solve touch issue look at this

@jafal According to the description on the Processing web site, ControlP5 is “A GUI library to build custom user interfaces for desktop and android mode.” If that’s not true, somebody should update the description so people won’t waste their time.

1 Like

I’m curious why you have two controllers for each slider? You might try taking one of the slider examples (File/Examples/ControlP5) and upsizing it for Android and see if that code runs ok on Android. One of the examples has multiple sliders.

Does the library work in Android mode?

It seems to me that there has been a problem in the past but unfortunately I can’t remember the details. I do know that I have made my own custom slider for Android so there must have been something wrong or I wouldn’t have felt the need to do that. Another option is to use an Android SeekBar as an alternative.

1 Like

Hi

All examples working on Android mode the issue with this library the touch not suitable to use as PC mouse

@jafal I looked at the Skatalo repository. Under the heading “What is the difference?”, it says:

" This library is for an advanced use of ControlP5, it is not as convenient to use. It is a part of a research and development project involving multi-touch, augmented reality and Ruby.

Please use the original library in your projects if you are not sure which one to use."

1 Like

the touch not suitable to use as PC mouse

?? We’re not using a PC mouse on Android.

Two conrollers for each slider? If you mean these lines, they’re only modifying the text attributes for the caption and value labels. Unless I’m totally out to lunch on this, I think I only have one controller for each slider.

1 Like

Hi

Sorry I mean not as using it on PC with mouse

It’s not just about getting the sliders to work. I have two more basic questions:

  1. According to the Processing web site, ControlP5 supports Android mode (“A GUI library to build custom user interfaces for desktop and android mode”). Is that true?

  2. Is anybody still supporting it, or is it orphanware? The open issues on the Github page haven’t been assigned to anybody.

There may be a larger problem than we think. @jafal is correct when he reports that touching the screen anywhere but one of the sliders will change the value(s). Try running your original demo and set one of the sliders then touch somewhere else on the screen (besides the other slider). On my system the slider value that was just set is changed. I think you may need to look for an alternative.

1 Like

Hi

Skatalo library changes the value of pressed slider there is no conflict as controlp5

Seems you’re right about that. Not only do you have to tap on the slider once to give it focus, then tap again to move it (a minor usability issue in my opinion), but tapping anywhere outside of the slider which currently has focus causes the slider to move (a major usability issue, in my opinion).

There doesn’t seem to be much point in opening an issue on the Github page if nobody is supporting it, though.

1 Like

It’s old issue and did not solved many reported it with no response