Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316197

Summary: setting the textLimit of the SWT Text ineffective
Product: [Eclipse Project] Platform Reporter: Josh O'Dowd <josh.odowd>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED WORKSFORME QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: skovatch
Version: 4.0   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:

Description Josh O'Dowd CLA 2010-06-08 15:42:02 EDT
Build Identifier: 20100218-1602

Greetings:

I am attempting to set a text limit on a Text widget and the widget is just allowing unlimited entry.

coding as follows

Text testText = new Text(testAreaComposite, SWT.NONE);
testText.setLayoutData(new TableWrapLayout(TableWrapLayout.FILL));
testText.setTextLimit(10);

The text widget is drawing fine but will not limit the user to 10 characters, as expected.

Thanks for your time.
JODowd

Reproducible: Always
Comment 1 Scott Kovatch CLA 2010-06-09 01:58:04 EDT
I'll assume you're using Cocoa, given how recent the build is.
Comment 2 Scott Kovatch CLA 2010-06-09 13:00:32 EDT
I can't reproduce this on 3.6rc4 in ControlExample. I can set a limit of 20 (for example) and can't type or paste beyond that.

How are you determining that you have a bug?
Comment 3 Josh O'Dowd CLA 2010-06-09 13:22:40 EDT
We are using SWT 3.6.  I am on an intel Mac running OSX10.6.3.  I ran the code snippet that I provided in the original bug description.  The text widget appears but does not limit the chars.

A fellow developer in our office is on a PC running Windows XP.  The same code is working on his machine and the character limit is enforced as expected...

Josh

(In reply to comment #2)
> I can't reproduce this on 3.6rc4 in ControlExample. I can set a limit of 20
> (for example) and can't type or paste beyond that.
> 
> How are you determining that you have a bug?
Comment 4 Scott Kovatch CLA 2010-06-09 14:39:21 EDT
Please attach a complete SWT example that demonstrates the bug. I'm not able to reproduce this with ControlExample, and the snippet below doesn't compile (TableWrapLayout has no FILL constant, for example.)  Thanks!
Comment 5 Josh O'Dowd CLA 2010-06-09 14:58:00 EDT
Yeah, Sorry, try this:


	import org.eclipse.swt.*;
	import org.eclipse.swt.layout.*;
	import org.eclipse.swt.widgets.*;

	public class LimitExample {

		public static void main(String[] args) {
			Display display = new Display();
			Shell shell = new Shell();
			shell.setLayout(new GridLayout(1, true));
			Text text;

			text = new Text(shell, SWT.NONE);
			text.setTextLimit(10);
			text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

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

This compiles, runs, draws, but does not limit chars on my machine...

***Note:  I have to have an environment variable (-d32) set on my eclipse run config to run any SWT 32 bit because I am on a 64 bit Mac.

Josh

(In reply to comment #4)
> Please attach a complete SWT example that demonstrates the bug. I'm not able to
> reproduce this with ControlExample, and the snippet below doesn't compile
> (TableWrapLayout has no FILL constant, for example.)  Thanks!
Comment 6 Scott Kovatch CLA 2010-06-09 15:17:47 EDT
The only thing I can suggest is to try a later build of 3.6. With the HEAD revision of SWT on I20100603-1500 it works as expected. I can type 10 characters and then keystrokes are ignored. You are using Cocoa, right?
Comment 7 Josh O'Dowd CLA 2010-06-10 11:41:59 EDT
Thanks for your time...

We are developing under eclipse 3.5 but are bundling and deploying with 3.6 SWT jars, so this works on my machine if I run the deployed product but does not work in my development environment.

Thanks again.

Josh O'Dowd

(In reply to comment #6)
> The only thing I can suggest is to try a later build of 3.6. With the HEAD
> revision of SWT on I20100603-1500 it works as expected. I can type 10
> characters and then keystrokes are ignored. You are using Cocoa, right?
Comment 8 Scott Kovatch CLA 2010-07-22 18:12:16 EDT
As noted, working in 3.6. We won't be releasing a 3.5 update.