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

Bug 320924

Summary: StyledText shows scrollbars after SWT.Settings change
Product: [Eclipse Project] Platform Reporter: Markus Keller <markus.kell.r>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, eclipse.felipe
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Markus Keller CLA 2010-07-26 12:14:33 EDT
I20100720-0800

StyledText shows scrollbars after SWT.Settings change.

- Run the snippet below.
- Start > Control Panel > Display: Change a setting, e.g. tooltip bg color.
=> StyledText now shows the vertical scroll bar although text.getVerticalBar().setVisible(false); has been called.

This is visible in the SDK when you open a text compare editor and then change a setting. The compare editor gets 2 additional scrollbars.


import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class Snippet {
    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);
        String contents= "1\n2\n3";
        text.setText(contents);
        text.getVerticalBar().setVisible(false);

        shell.pack();
        text.append("\n4\n5\n6");

        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}
Comment 1 Felipe Heidrich CLA 2010-07-27 09:34:08 EDT
Note, calling text.getVerticalBar().setVisible(false) is not correct (same as setSelection,setMaximum, set*).

StyledText is the owner of its scrollbars, it will call setters on it constantly and it will most likely override the setting the application set.
Comment 2 Markus Keller CLA 2010-07-27 09:57:22 EDT
Compare has been doing that for a long time, and they need this to show/hide the bars on-the-fly when the user toggles the setting to synchronize scrolling between the text panes.

An alternative could be that SWT offers some other way to toggle the V_SCROLL and H_SCROLL styles on an existing StyledText widget.
Comment 3 Felipe Heidrich CLA 2010-07-27 16:06:18 EDT
(In reply to comment #2)
> Compare has been doing that for a long time, and they need this to show/hide
> the bars on-the-fly when the user toggles the setting to synchronize scrolling
> between the text panes.

We could recreate the text widget when the option changes...

I tried to reproduce the problem on Eclipse and using the snippet and it worked for me. Running SWT from HEAD on Windows XP SP3 Classic theme. (changing the tooltip color to cause setting events).
Comment 4 Markus Keller CLA 2010-07-28 06:54:56 EDT
(In reply to comment #3)
> I tried to reproduce the problem on Eclipse and using the snippet and it worked
> for me. Running SWT from HEAD on Windows XP SP3 Classic theme. (changing the
> tooltip color to cause setting events).

Wow, this only happens in the XP theme but not in the Classic theme.
Comment 5 Felipe Heidrich CLA 2010-08-09 16:02:46 EDT
(In reply to comment #4)
> Wow, this only happens in the XP theme but not in the Classic theme.

This is strange, win32 is reshowing the scrollbar behind the scenes for no apparent reason.
I can't think of any easy fix for this but finding all scrollbars and hinding them again if (state & HIDDEN) != 0.
Comment 6 Eclipse Webmaster CLA 2019-09-06 16:14:11 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.

If you have further information on the current state of the bug, please add it. 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.
Comment 7 Eclipse Genie CLA 2021-10-31 18:56:35 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.