Waiting cursor "best practice" [message #1016644] |
Thu, 07 March 2013 04:05  |
Eclipse User |
|
|
|
Hi,
In my project I define two methods to set the mouse cursor to wait or default (arrow) one, as needed:
private Cursor waitCursor;
private Cursor arrowCursor;
/**
* Set cursor to wait cursor
*/
public void setCursorToWait() {
shell.setEnabled(false);
if (waitCursor == null) {
waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
}
shell.setCursor(waitCursor);
}
/**
* Set cursor to default cursor
*/
public void setCursorToDefault() {
if (arrowCursor == null) {
arrowCursor = new Cursor(display, SWT.CURSOR_ARROW);
}
shell.setCursor(arrowCursor);
shell.setEnabled(true);
}
As you can see, I not only change the cursor but also disable the Shell to prevent the user from clicking while the program is busy with a "long" task.
But I've just found out that the call to the setEnabled method of the Shell class causes a focus lost event from my current widget, which generates problems in some cases, notably when the current widget has a FocusListener.
My questions are:
> Is it necessary to disable the shell ?
> Is this the best way to set a waiting indicator ?
Thanks !
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04861 seconds