MaterialFX icon indicating copy to clipboard operation
MaterialFX copied to clipboard

How to set our own TextFormatter on MFXTextField

Open chuckdu21 opened this issue 2 years ago • 0 comments

Hi, I'd like to set my own TextFormatter on a MFXTextField but i get this error: formatter is already used in other control

I tried to unbind the textformatter, even on the boundField but my TextFormatter won't set. (I tried the same textformatter on a default TextField and it's working).

Here's a sample of my code:


public class MFXDateTimeField extends MFXTextField {
    UnaryOperator<TextFormatter.Change> filter;

    public MFXDateTimeField() {
        super();
        this.filter = c -> {
            if (c.isAdded()) {
                c.setRange(c.getRangeStart(),
                        Math.min(c.getControlText().length(), c.getRangeStart() + c.getText().length()));
            }
            return c;
        };
        this.setTextFormatter(new TextFormatter<Object>(filter));

How can i "force" to set my TextFormatter or something like this ?

chuckdu21 avatar Oct 11 '22 06:10 chuckdu21