Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Waiting cursor "best practice"(How to use the waiting cursor in the best way ?)
Waiting cursor "best practice" [message #1016644] Thu, 07 March 2013 09:05 Go to next message
hortiz Mising name is currently offline hortiz Mising nameFriend
Messages: 96
Registered: July 2009
Member
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 !


Re: Waiting cursor "best practice" [message #1017141 is a reply to message #1016644] Sat, 09 March 2013 20:30 Go to previous messageGo to next message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Why do not use an BusyIndicator?

// Show a busy indicator while the runnable is executed
BusyIndicator.showWhile(display, runnable); 


Time is what you make of it.
Re: Waiting cursor "best practice" [message #1017680 is a reply to message #1017141] Tue, 12 March 2013 10:14 Go to previous message
hortiz Mising name is currently offline hortiz Mising nameFriend
Messages: 96
Registered: July 2009
Member
Ok thanks I will try this
Previous Topic:SWT Graphics and Controls
Next Topic:Problem using focus listener
Goto Forum:
  


Current Time: Thu Apr 25 06:56:26 GMT 2024

Powered by FUDForum. Page generated in 0.03183 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top