Community
Participate
Working Groups
In the example below, the tabs ('\t') are still expanded in spite of the setTabs(1). If not SWT.SINGLE, then the tabs *are* expanded correctly to one space character each. ============================================================================== import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class Main { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell(display); Text text = new Text(shell, SWT.SINGLE | SWT.BORDER); text.setBounds (10, 10, 1000, 60); text.setTabs(1); text.append("1\t12\t123\t1234\t12345\t123456\t1234567\t12345678\t12345678"); shell.open (); //text.setSelection (30); //System.out.println (text.getCaretLocation ()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
Actually, when not SWT.SINGLE, it *also* needs SWT.V_SCROLL in order to consider the setTabs() call!? Without the V_SCROLL, it still expands tabs to 8-space tab stops...
I just tried this on WindowsXP and I do not get the behaviour you are describing. I am using Eclipse 2.1 RC2 and you appear to be using Eclipse 2.0.2, which may be the reason. 1)In the SWT.SINGLE case, the '\t' character is displayed as an invalid character (in my font, this is a square but it could be a question mark or some other weird symbol depending on the font). This is expected because tabs are invalid in single line text widgets. If you hit the tab key when in a single line text widget, you will traverse to the next widget in the tab order. 2) In the SWT.MULTI case without scrollbars, the tabs appeared as a single space. Adding scrollbars made no difference. I recommend you upgrade to Eclipse 2.1. There is currently no plan to back port this behaviour to Eclipse 2.0.
Works as expected in Eclipse 2.1 RC2.