Project: SWT
Bug 57647 errant ON_TOP | SYSTEM_MODAL Shell behaviour if tooltiptext is set on any control
Reported: 2004-04-06 16:04:49 | Status: resolved fixed

Shell ON_TOP behaviour stops when a tooltiptext is set for any control on the shell. The window goes to the background and never regains ON_TOP state again. Tried it with 2.1.2 and v.3.0 I20040406. The recent version improved: shell loosing ON_TOP only when I hover for the tooltip. Plase see sample code and explanation. Thanks. package com.test; /* * Created on Mar 31, 2004 * ECLIPSE Version 2.1.2 - 3.0 * This small example was created using * SWT Designer Free edition from Instantiations * Issue: * errant ON_TOP | SYSTEM_MODAL Shell behaviour * How to test the flaw: * Run the app: * 1. click once to a list selection entry * 3. click once outside of the shell window (click on the app.behind) * 4. click once on the surface of the shell * 5. click again outside of the shell. * The last time click removes the shell window's ON_TOP behaviour. It will never regain * ON_TOP again. * What's causing it? * Close the shell. * Comment out the last line that sets the tooltip text. Compile. * Try the previous steps again. It doesn't matter how many times you click, * the shell keeps its ON_TOP habit as expected. * */ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.RowData; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.graphics.Font; /** * Usage: Run it as any other SWT code under Eclipse: * Run.. -> New -> * VM arguments: -Djava.library.path=D:\eclipse\plugins\org.eclipse.swt.win32_2.1.2\os\win32\x86 * */ public class TestSWT3 { protected Shell shell; public List list ; public String tooltipStr = "When you see this, you'll loose ON_TOP..."; public String currentTip; public static void main(String[] args) { TestSWT3 window = new TestSWT3(); window.open(); } public void open() { final Display display = new Display(); createContents(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } shell.dispose(); display.dispose(); } protected void createContents() { shell = new Shell(SWT.CLOSE | SWT.SYSTEM_MODAL | SWT.TITLE | SWT.ON_TOP); final RowLayout rowLayout_1 = new RowLayout(); rowLayout_1.spacing = 0; shell.setLayout(rowLayout_1); shell.setSize(500,240); shell.setText("SWT ToolTipText flaw..."); final Composite composite = new Composite(shell, SWT.BORDER); final GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 2; gridLayout.marginHeight = 2; gridLayout.numColumns = 3; composite.setLayout(gridLayout); final RowData rowData = new RowData(); rowData.height = 25; rowData.width = 480; composite.setLayoutData(rowData); final Label label = new Label(composite, SWT.BORDER | SWT.SHADOW_IN); label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); final GridData gridData = new GridData(GridData.GRAB_HORIZONTAL); gridData.widthHint = 150; label.setLayoutData(gridData); label.setText("label"); final Label label_1 = new Label(composite, SWT.BORDER | SWT.SHADOW_IN); final GridData gridData_1 = new GridData(GridData.GRAB_HORIZONTAL); gridData_1.widthHint = 150; label_1.setLayoutData(gridData_1); label_1.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); label_1.setText("label"); final Label label_2 = new Label(composite, SWT.BORDER | SWT.SHADOW_IN); final GridData gridData_2 = new GridData(GridData.GRAB_HORIZONTAL); gridData_2.widthHint = 150; label_2.setLayoutData(gridData_2); label_2.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); label_2.setText("label"); final Group group = new Group(shell, SWT.NONE); final RowData rowData_1 = new RowData(); rowData_1.height = 48; rowData_1.width = 480; group.setLayoutData(rowData_1); final RowLayout rowLayout = new RowLayout(); rowLayout.marginBottom = 1; rowLayout.spacing = 0; rowLayout.justify = true; rowLayout.marginTop = 1; group.setLayout(rowLayout); final Label label_3 = new Label(group, SWT.BORDER | SWT.CENTER | SWT.HORIZONTAL); final RowData rowData_2 = new RowData(); rowData_2.width = 470; label_3.setLayoutData(rowData_2); label_3.setFont(new Font(Display.getCurrent(),"Microsoft Sans Serif", 18, SWT.NONE)); label_3.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); label_3.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)); label_3.setText("label"); final Group group_1 = new Group(shell, SWT.NONE); final RowData rowData_4 = new RowData(); rowData_4.height = 76; group_1.setLayoutData(rowData_4); group_1.setLayout(new RowLayout()); final Composite composite_1 = new Composite(group_1, SWT.NONE); final RowData rowData_3 = new RowData(); rowData_3.width = 480; composite_1.setLayoutData(rowData_3); final GridLayout gridLayout_1 = new GridLayout(); gridLayout_1.numColumns = 2; composite_1.setLayout(gridLayout_1); final Button button = new Button(composite_1, SWT.NONE); button.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_CENTER)); button.setText("button"); list = new List(composite_1, SWT.BORDER); list.setItems(new String[] { "one", "two", "three" }); list.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_CENTER)); list.setToolTipText(tooltipStr); } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java