Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338177 - Text field getText() truncates last character
Summary: Text field getText() truncates last character
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 410623 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-02-25 01:45 EST by Bryan Hunt CLA
Modified: 2013-12-13 11:41 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Hunt CLA 2011-02-25 01:45:07 EST
I'm running Eclipse 3.7M5 and when I call getText() on a text field that contains the text "Group 2", I get back "Group ".  The problem occurs when I press the finish button on the wizard and the text field still has focus.  If I tab to the next text field, the full value of the text field will be properly returned on a call to getText().  This problem appears to be specific to Cocoa as I do not see the problem on my Linux box.
Comment 1 Lakshmi P Shanmugam CLA 2011-02-25 06:23:33 EST
I'm unable to reproduce this with HEAD. Here is the snippet I tried with and getText() works fine here. Does this work for you? Can you please post a simple snippet to show the problem?

public class Bug_338177 {
public static void main(String[] args) {
	Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new GridLayout(1, false));
	final Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
	text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
	text.setText("Group 2");
	Button button = new Button(shell, SWT.PUSH);
	button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
	button.setText("gettext");
	button.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			System.out.println(text.getText());
		}
	});
	shell.setDefaultButton(button);
	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
}
Comment 2 Lakshmi P Shanmugam CLA 2012-07-18 07:42:16 EDT
I'm unable to reproduce this with eclipse 3.8/4.2. Please reopen this bug if you are able to supply us with some reproducible steps.
Comment 3 Markus Keller CLA 2013-11-26 10:07:27 EST
*** Bug 410623 has been marked as a duplicate of this bug. ***
Comment 4 Ralf Teusner CLA 2013-12-13 11:41:43 EST
Hi Lakshmi,

your code snippet works for me. And as of now, I can't reproduce the bug on my system any longer (changed my SDK several times since then).

If I encounter it again, I will provide a small snippet, but so far no "luck".

Thanks for your efforts!