Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 34805 - Text (SWT.SINGLE) ignores setTabs()
Summary: Text (SWT.SINGLE) ignores setTabs()
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-12 09:14 EST by adrian CLA
Modified: 2003-03-12 09:39 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description adrian CLA 2003-03-12 09:14:27 EST
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();
}
}
Comment 1 adrian CLA 2003-03-12 09:24:14 EST
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...
Comment 2 Veronika Irvine CLA 2003-03-12 09:36:32 EST
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.
Comment 3 Veronika Irvine CLA 2003-03-12 09:39:49 EST
Works as expected in Eclipse 2.1 RC2.