Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JITHU1903 opened this issue Nov 3, 2022 · 4 comments
Milestone

Comments

@JITHU1903
Copy link

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
Copy link
Author

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
Copy link
Contributor

lcaron commented Nov 4, 2022

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
Copy link
Author

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 lcaron added this to the 3.1.0 milestone Mar 7, 2023
@lcaron lcaron modified the milestones: 3.1.0, 3.2.0 Dec 23, 2023
@lcaron
Copy link
Contributor

lcaron commented Dec 23, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants