Having font issue with ControlP5 GUI library

I am having an issue with setting the font of the DropdownList items, I know how to edit the font of the caption labels but can't figure out how to do the same for the items in the menu. I really need to make the font bigger as it is so tiny I am struggling to read it on my screen, and that means the end user will have just as hard of a time.

What I have done to change the font of the labels is:

ControlP5 main = new ControlP5(this);
ControlFont font = new ControlFont(createFont("Arial", 18, true), 241);
//^^^^ For reference

main.getController("Select_Vehicle")    // <- Select_Vehicle is a button, this is just a reference to how I have done it so far
    .getCaptionLabel()
    .setFont(font)
    .toUpperCase(false)
    .setSize(14);

This works very well for things that only have labels, but this will not change the font for the items in the dropdown menu. What I thought was maybe I need to replace the .getCaptionLable() with something similar that grabs the items from the menu and allows me to then change it, but what I have tried never worked, then again I haven't been able to try much.

Answers

  • edited January 2017 Answer ✓

    You were on the right track, the function you were searching for is "getValueLabel()".

    I changed the ScrollableList-example to show how to use it:

    import controlP5.*;
    import java.util.*;
    
    ControlP5 cp5;
    
    void setup() {
      size(400, 400);
      cp5 = new ControlP5(this);
      List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
    
      ScrollableList list = cp5.addScrollableList("dropdown")
        .setPosition(100, 50)
        .setSize(200, 300)
        .setBarHeight(60)
        .setItemHeight(60)
        .addItems(l)
        ;
    
    
      // create a control-font 
      PFont pfont = createFont("Arial", 24, true);
      ControlFont font = new ControlFont(pfont, 24);
      // set font for label
      list.getCaptionLabel().setFont(font);
      // set font for values
      list.getValueLabel().setFont(font);
    }
    
    void draw() {
      background(240);
    }
    
  • That makes more sense...Thank you so much for the help. :x

Sign In or Register to comment.