controlP5 InputFilter

edited February 2014 in Library Questions

Hi. I'm struggling to understand how to use the InputFilter in a textfield According to http://www.sojamo.de/libraries/controlP5/reference/index.html?controlP5/Textfield.html there are four options.

So when i want to allow ONLY Integers the .setInputFilter(ControlP5.INTEGER); is used.

BUT.. what can i do if i want to allow a compination of characters ?

In a date field for example i want to use 31-1-2013 (Integers AND the - symbol). There is a way to allow ONLY the "selected" characters ?

Thank you in advance.

Answers

  • Answer ✓

    How about making three separate text fields (day, month, year) that allow only integer input, since the - isn't real 'input' anyway as it is fixed. Plus it will make it easier to do check for correct input: max 31, max 12, etc.

  • Yes.... i already working on this idea. Thank you.

    The question was cause i want to understand HOW TO FILTER the inputs in a textfield.

    I have found this http://www.sojamo.de/libraries/controlP5/reference/controlP5/Textfield.InputFilter.html#DEFAULT where it defines how to use inputFilter...but i can't understand how to use the DEFAULT option .

  • I just found this that will do the job.. :)

    cp5.addTextfield("DATE")
      .setText(day() + "-" + month() + "-" + year() )
        .setPosition(355, 35)
          .setSize(120, 30)
            .setFont(createFont("arial", 20))
              .setFocus(false)
                .setColor(color(255, 0, 0))
                  ;         
    
Sign In or Register to comment.