[ControlP5] How can i hide the Labels from ListItems?

edited September 2014 in Library Questions

hellou,
sometimes the label is too long :/
LabelTooLong
is it possible to hide the captionLabels from the Items in the Background?

import controlP5.*;
ControlP5   cp5;
DropdownList l; 

PFont myFont;
void setup() {
  size(1000, 500);
  cp5 = new ControlP5(this);

  l = cp5.addDropdownList("myList")
    .setPosition(100, 100)
      ;

  String[] fontList = PFont.list();
  for (int i=0; i<fontList.length; i++) {
    l.addItem(fontList[i], i);
  }

  myFont = createFont("Arial", 20);
}

void draw() {
  background(90);

}

Answers

  • edited September 2014

    my wish:
    LabelTooLong2
    (photoshop :P)

  • Answer ✓

    Just shorten it before you add it to the list. For example methods that might be useful for such a task are String.substring(start, end), String.length(), perhaps even textWidth(String).

  • edited September 2014

    understand. but its a little detour.

    is there any place where i can suggest improvements like these? Anyway do the founder/developer support the cp5 yet today?

    (srry for my bad english)

  • edited September 2014

    Well, it's only 1 or 2 lines of code...

    It seems ControlP5 was just moved to GitHub, nice!

    See: https://github.com/sojamo/controlp5

    Issues: https://github.com/sojamo/controlp5/issues

  • edited September 2014

    thx for this link ;)

    To the thread:
    Now, another problem appears, when it is cutted:
    BOOKMAN OLD STYLE FET
    BOOKMAN OLD STYLE FET

    I can not see if it is:
    BOOKMAN OLD STYLE FETT
    or it is
    BOOKMAN OLD STYLE FETT KURSIV
    :O

  • Well, what did you expect? That is obviously the consequence of cutting the end of the name (as you showed you wanted). Options to solve this:

    1. Accept it.
    2. Increase the width of the list.
    3. Use the ControlP5 selected item's index on the original String list to retreive the full name for the font.
    4. Shorten the name differently. Instead of capping the end, remove parts in the middle.
Sign In or Register to comment.