Hi!
 
We have an extension that extends ULC/UITextField. We have overridden updateToModel to reformat the typed string after the typing is finished:
    protected void updateToModel(final boolean displayFormattedValue)
    {
          super.updateToModel(displayFormattedValue);
          if (displayFormattedValue)
          {
              getBasicTextComponent().setText(reformat(getBasicTextComponent().getText()));
          }
    }
 
The problem with this is that it sometimes an extra valueChangedEvent after leaving the textfield.An alternative looks like this
    protected void updateToModel(final boolean displayFormattedValue)
    {
          super.updateToModel(displayFormattedValue);
          if (displayFormattedValue)
          {
              setText(reformat(getBasicTextComponent().getText()));
          }
    }
Now the extra event isn't created, but the text changes to the originally typed in text when the textfield gets the cursor again.
For example if I typed in "1020", it is displayed as "10:20" after the reformatting and again as"1020" once I click into the textfield.
 
Is there some way to reformat the text and make it stay reformatted without the extra valueChangedEvent?
 
Cheers and thanks in advance,
  Robert

 

Reply via email to