Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 286254 - [Text] setTextLimit doesn't cut existing text
Summary: [Text] setTextLimit doesn't cut existing text
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.3 M2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-11 10:56 EDT by Benjamin Muskalla CLA
Modified: 2009-08-28 04:03 EDT (History)
0 users

See Also:


Attachments
Proposed patch (4.81 KB, text/plain)
2009-08-25 10:16 EDT, Asen Draganov CLA
no flags Details
Proposed patch (12.41 KB, patch)
2009-08-26 09:52 EDT, Asen Draganov CLA
ruediger.herrmann: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Muskalla CLA 2009-08-11 10:56:53 EDT
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();
		}
Comment 1 Ivan Furnadjiev CLA 2009-08-13 10:43:48 EDT
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.
Comment 2 Asen Draganov CLA 2009-08-25 10:16:40 EDT
Created attachment 145542 [details]
Proposed patch

Text, Combo and CCombo are corrected. The behavior is as explained by Ivan in Comment #1.
Comment 3 Asen Draganov CLA 2009-08-26 09:52:38 EDT
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.
Comment 4 Rüdiger Herrmann CLA 2009-08-27 10:56:06 EDT
Applied second patch to CVS HEAD