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

Bug 300587

Summary: SWT.SINGLE Text fails to show all content when resized larger (Text.setBounds bug)
Product: [Eclipse Project] Platform Reporter: Doug M <eclipse>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact: Felipe Heidrich <eclipse.felipe>
Severity: normal    
Priority: P3 CC: eclipse, lshanmug, Silenio_Quarti
Version: 3.5.1Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Attachments:
Description Flags
Demo of bug none

Description Doug M CLA 2010-01-22 19:26:44 EST
Build Identifier: swt-3.5.1-win32-win32-x86

When typing at the right end of a single-line Text (implemented as Edit Control), Windows scrolls the text left to keep caret in view. If the Text is resized to show the full content, it remains scrolled with the start of the text invisible.

This problem is specifically identified in Text.setBounds. The author writes a fix that I believe is supposed to be triggered by testing whether the text width is greater than the control width. However, the control's width is actually compared to the control's margins alone (as in its trim), without adding in the text width. Therefore the fix is not done when it is needed and part of the text remains cut off.

Reproducible: Always

Steps to Reproduce:
See attached demo TextResize.java.

A workaround for my particular application is after resizing, to detect that the caret is at the right edge, and then send the caret to the beginning and back to the end. This is demonstrated in the example. But it won't work in general since the shift may occur when the caret is not at the far right.

Solutions I have tried that did not work:
1) Turning off horizontal autoscroll. 
     *              int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
     *              bits &= ~OS.ES_AUTOHSCROLL;
     *              OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
The shifting of the caret into view must be unrelated to autoscroll.

2)   Sending the message that
     * is supposed to scroll Edit Controls. Although as usual, MS documentation
     * is vague about whether this works with single-line controls. 
     * In any case, it also does not work.
     *       OS.SendMessage(handle, OS.EM_LINESCROLL, 2, 2);//-2,-2 also fails

3) Creating the Text with SWT.RIGHT. It does stop the scrolling,
      but introduces a severe flicker, with redraw errors.
(sorry - another bug.)
Comment 1 Doug M CLA 2010-01-22 19:29:46 EST
Created attachment 157022 [details]
Demo of bug
Comment 2 Lakshmi P Shanmugam CLA 2010-02-11 10:20:41 EST
I can reproduce this with a simple SWT snippet.
As mentioned in comment 1, there is code(& comments) in Text.setBounds to workaround this windows bug, but the fix is not called when it is required.
Comment 3 Felipe Heidrich CLA 2010-03-16 15:06:44 EDT

*** This bug has been marked as a duplicate of bug 277618 ***
Comment 4 Felipe Heidrich CLA 2010-03-30 14:41:50 EDT
The problem with Combo was similar but not the same. Reopening.
Comment 5 Leo Ufimtsev CLA 2017-08-03 12:33:30 EDT
This is a one-off bulk update. (The last one in the triage migration).

Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process:
https://wiki.eclipse.org/SWT/Devel/Triage

See Bug 518478 for details.

Tag for notification/mail filters:
@TriageBulkUpdate
Comment 6 Eclipse Genie CLA 2020-04-15 11:39:00 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.