Quantcast

How to set CommitOnSelChange on a Combo-box?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

How to set CommitOnSelChange on a Combo-box?

try67
I'm creating a combo-box, and I want to set it to commit the selected value immediately.
I can't seem to find this as a separate property of PdfFormField, so I looked it up in the PDF reference and found that this field is on bit position 27. I tried setting the field's flags to 27, but that didn't seem to work...
Any advice on how to achieve it?

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to set CommitOnSelChange on a Combo-box?

davidxn
An example solution is as follows:

    String[] values = {"1", "2", "3"};
    String[] options = {"One", "Two", "Three"};
    TextField text = new TextField(writer, new Rectangle(50, 700, 120, 715), "cmbTest");
    text.setChoices(options);
    text.setChoiceExports(values);
    text.setChoiceSelection(0);
    PdfFormField combo = text.getComboField();
    combo.setFieldFlags(67108864); // Setting bit 27 = value of 2^26
    writer.addAnnotation(combo);

Thank you for your question; it led me in the right direction.
Loading...