[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform.swt] Shell setMinimized() & activation
|
Should calling setMinimized(true) on a Shell be equivalent to
minimizing the shell using the frame bar button? Specifically, should it
fire a Shell deactivated event. Here's a code snipped to illustrate
the problem:
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.SWT;
public class Question
{
public static void main(String[] args)
{
final Display display = new Display();
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setLayout(new FillLayout(SWT.HORIZONTAL));
shell.addListener(SWT.Deactivate, new Listener()
{
public void handleEvent(Event e)
{
System.out.println("Shell Deactivated");
}
});
Button b = new Button(shell, SWT.PUSH);
b.setText("Minimize");
b.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event e)
{
shell.setMinimized(true);
}
});
shell.setSize(200, 100);
shell.open();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Clicking the minimize button in the framebar (on Windows it's the _ button)
causes 3 things to happen:
1. The shell is collapsed to the taskbar.
2. A shell deactivation event to be fired.
3. The window immediately under the shell (if any) is made active.
Now, when setMinimized(true) is called on the shell, via the SWT button,
only 1 occurs. No deactivation event is fired and no other window is made
active.
I've run into this problem as I'm writing a class to let you flash a shell
on Windows. One of the supported modes is flash until active. I was trying
to test this code by inactivating a shell by calling setMinimized(true)
and then cause it to flash. The shell collapses to the taskbar but never
flashes, since it's still active.
So, is this a bug in setMinimized on Windows? If not, is there some other
way of programmatically deactivating a shell?
Cheers,
Alun