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

Bug 97366

Summary: StyledText: problem using setHorizontalIndex when StyledText is not realized
Product: [Eclipse Project] Platform Reporter: Felipe Heidrich <eclipse.felipe>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: cholerikasi, eclipse
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 93845    

Description Felipe Heidrich CLA 2005-05-30 17:22:51 EDT
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setLayout(new FillLayout());
	StyledText text = new StyledText (shell, SWT.V_SCROLL|SWT.H_SCROLL);
//	shell.open();//uncomment this line to fix the bug
	text.setText("public abstract class Item extends Widget {\n\n * @param 
parent a widget which will be the parent of the new instance (cannot be 
null)");
	text.setHorizontalIndex(22);
	shell.setSize(400, 409);	
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
Comment 1 Felipe Heidrich CLA 2005-05-30 17:24:56 EDT
run the snippet, the styledtext is scrolled to the right. it is unnecessary to 
scroll all way to the right to show offset 22.

Comment 2 Tobias Flach CLA 2007-05-13 17:42:26 EDT
Hi,

I tried to reproduce the error but in my window it is necessary to scroll all the way to the right to show offset 22. But I'm a bit confused that the scroll bar is either moving all the way to the right (if it has to move to the right end due to the offset) or staying at it's initial position (if it has not to move completely to the right end).
Comment 3 Felipe Heidrich CLA 2007-05-15 15:58:35 EDT
I checked this method again.
It works fine as long as the offset is in the first line and font is fixed (monospace).

Personally I would have implemented this differently but the current implementation is from 2003 I don't think we can changed it now.
closing.