Community
Participate
Working Groups
Calling setTextLimit on a Text works as expected but in SWT the exisiting text is cut down to not exceed the limit. In RAP this is not the case. Snippet: Display display = new Display(); final Shell shell = new Shell(display); shell.setSize(200, 200); shell.setLayout(new GridLayout()); final Text text = new Text(shell, SWT.SINGLE | SWT.LEAD | SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); text.setText("a"); Button button = new Button(shell, SWT.PUSH); button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); button.setText("setTextLimit(3)"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { text.setTextLimit(3); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); }
On Windows the setTextLimit() does not cut the existing text, but the text that is set after the text limit. For example: 1. setText("Alabala"); 2. setTextLimit(3); 3. getText() returns "Alabala" 4. setText("Balabala"); 5. getText() returns "Bal" This bug is valid for Combo and CCombo too.
Created attachment 145542 [details] Proposed patch Text, Combo and CCombo are corrected. The behavior is as explained by Ivan in Comment #1.
Created attachment 145675 [details] Proposed patch Please, use this patch. Compared with the previous one, some new test cases were added in the JUnit tests regarding the VerifyEvent.
Applied second patch to CVS HEAD