Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332282 - The styledtext caret position is incorrect when switch Orientation
Summary: The styledtext caret position is incorrect when switch Orientation
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 29779
Blocks:
  Show dependency tree
 
Reported: 2010-12-10 03:54 EST by yanghang CLA
Modified: 2011-01-25 16:35 EST (History)
1 user (show)

See Also:


Attachments
original size (9.77 KB, image/jpeg)
2010-12-10 03:55 EST, yanghang CLA
no flags Details
change bigger (11.75 KB, image/jpeg)
2010-12-10 03:57 EST, yanghang CLA
no flags Details
change smaller (7.30 KB, image/jpeg)
2010-12-10 03:58 EST, yanghang CLA
no flags Details
sample code (1.79 KB, text/x-java-source)
2010-12-10 10:04 EST, yanghang CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description yanghang CLA 2010-12-10 03:54:08 EST
Build Identifier: SWT3.4.2

switch styledtext Orientation, and resize styledtext size, the caret position is incorrect.

Reproducible: Always

Steps to Reproduce:
1. launch my sample code
2. press CTRL+G to swith Orientation from LTR to RTL
3. resize the shell

Bug:
if change size smaller, the caret is lost;
if change size bigger, the caret is not at line end
Comment 1 yanghang CLA 2010-12-10 03:55:45 EST
Created attachment 184927 [details]
original size
Comment 2 yanghang CLA 2010-12-10 03:57:37 EST
Created attachment 184928 [details]
change bigger
Comment 3 yanghang CLA 2010-12-10 03:58:35 EST
Created attachment 184929 [details]
change smaller
Comment 4 yanghang CLA 2010-12-10 10:04:47 EST
Created attachment 184957 [details]
sample code
Comment 5 Felipe Heidrich CLA 2010-12-10 15:06:56 EST
I suspect this is a bug in Windows and should be fixed when we finish Bug 29779.
Comment 6 Felipe Heidrich CLA 2010-12-10 16:08:45 EST
The bug is here: Canvas
LRESULT WM_WINDOWPOSCHANGED (int /*long*/ wParam, int /*long*/ lParam) {
	LRESULT result  = super.WM_WINDOWPOSCHANGED (wParam, lParam);
	//if (result != null) return result;
	/*
	* Bug in Windows.  When a window with style WS_EX_LAYOUTRTL
	* that contains a caret is resized, Windows does not move the
	* caret in relation to the mirrored origin in the top right.
	* The fix is to hide the caret in WM_WINDOWPOSCHANGING and
	* show the caret in WM_WINDOWPOSCHANGED.
	*/
	boolean isFocus = (style & SWT.RIGHT_TO_LEFT) != 0 && caret != null && caret.isFocusCaret ();
	if (isFocus) caret.setFocus ();
	return result;
}

Set orientation for StyledText does not update the style field.
So this (style & SWT.RIGHT_TO_LEFT) != 0 still returns false after StyledText#setOrientation(SWT.RIGHT_TO_LEFT)

This will be fixed when we fix Bug 29779.
If we don't fix Bug 29779, we can fix this bug by adding:
int style = getStyle(); before the test.
Comment 7 Felipe Heidrich CLA 2010-12-23 14:40:19 EST
Fixed in HEAD.