eclipse / nebula

Nebula Project
https://eclipse.org/nebula
Eclipse Public License 2.0
85 stars 98 forks source link

FormattedText.MaskFormatter doesn't work as expected in RAP(Remote Application Platform) #493

Open JITHU1903 opened 1 year ago

JITHU1903 commented 1 year ago

I have a formatted text field and a mask applied to it. when typing numbers in the field the typed number fields will appear randomly in RAP..

To give more context of the behaviour for example i have a mask applied to the field (###) ### - #### and I have numbers partially filled (123) 4- and try to insert a 5 (i.e. (1235) 4 before it corrects the value) this is the input to MaskFormatter.insetText(String txt, int start)

  1. In Non-RAP this is working fine number 5 entering to the right mask (123) 45 cursur position is 4
  2. but this is not the case in RAP the number 5 entering to (1235) 4 cursor position is 0

In Non-RAP it is reconciling 1 character at a time but in RAP it is trying to do it with the whole string.

JITHU1903 commented 1 year ago

Untitled design

The number entering to the field first is non problematic field when opened in RCP The number entering second time is when opened in RAP

lcaron commented 1 year ago

Hi

Can you please post a sample code that reproduces the bug ?

I think it will be difficult to find people who are cumfortable with RAP... Do you think you can provide a patch ?

Laurent

JITHU1903 commented 1 year ago

the sample is very similar to the example snippet 1 provided NumberFormatter, instead I am using MaskFormatter

package org.eclipse.nebula.snippets.formattedtext;

import java.util.Locale;

import org.eclipse.nebula.widgets.formattedtext.FormattedText; import org.eclipse.nebula.widgets.formattedtext.MaskFormatter; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell;

public class MaskFormatter { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout());

Locale.setDefault(Locale.US);
FormattedText text = new FormattedText(shell, SWT.BORDER | SWT.RIGHT);
text.setFormatter(new MaskFormatter("(###) ###-###"));
GridData data = new GridData();
data.widthHint = 100;
text.getControl().setLayoutData(data);

shell.open();
while ( ! shell.isDisposed() ) {
    if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

}

lcaron commented 10 months ago

Sorry for my late answer. Do you think you can provide a patch ?