ControlP5 textfield and position

edited July 2014 in Library Questions

hi guys, i have a little problem, I would like to hide the text that appears below the TextField, i try but did not work and I do not know how to do. :-B . Another problem I found is the location, I had to put a list box and a text fiel at the same height, but does not work, for the listbox is 300px while for the textfiel is 269px!!! how is this possible? can someone help me? I'm new with processing!!

Tagged:

Answers

  • Post a runnable example that displays the issues you describe. Then we can help you with your problem.

  • edited July 2014
        import controlP5.*;
    
        ControlP5 cp5;
    
        ListBox l;
    
        int cnt = 0;
        PFont font = createFont("arial",20);
        void setup() {
          size(700, 400);
          background(0);
          ControlP5.printPublicMethodsFor(ListBox.class);
    
          cp5 = new ControlP5(this);
          l = cp5.addListBox("myList")
                 .setPosition(100, 100)//<------position
                 .setSize(120, 120)
                 .setItemHeight(15)
                 .setBarHeight(15)
                 .setColorBackground(color(255, 128))
                 .setColorActive(color(0))
                 .setColorForeground(color(255, 100,0))
                 ;
          l.captionLabel().toUpperCase(true);
          l.captionLabel().set("A Listbox");
          l.captionLabel().setColor(0xffff0000);
          l.captionLabel().style().marginTop = 3;
          l.valueLabel().style().marginTop = 3;
    
           cp5.addTextfield("input")
             .setPosition(225,100)//<-----position
             .setSize(120,120)
             .setFont(font)
             .setFocus(true)
             .setColor(color(255,0,0))
             ;
        }
        //same position different altitude
        //i want hide input under the textfield
    
  • edited July 2014 Answer ✓

    There are two ways to remove the input title:

    1. Change line 30 to: cp5.addTextfield("")
    2. Add extra line after line 35: .setLabel("")

    I think the listBox's barHeight is subtracted from the listBox vertical position. There is not really a method() to 'solve' this, it's just designed that way I believe. To position the controllers identically, you can use:

          int barHeight = 15;
                 .setPosition(100, 100 + barHeight + 1) // whatever works!
                 .setBarHeight(barHeight)
    
  • thanks its was perfect

Sign In or Register to comment.