Change MouseCursor for entire application, and disable UI


How do I prevent user from performing any UI operations on say a click of a particular button. There are two things I need to do,

  1. show a wait cursor informing the user that there is some process thats happening in the background, once this process is completed, the default mousecursor will be loaded and UI will be enabled to the user.
  2. Prevent user from performing any UI operation, like say clicking on menubars, closing the app, entering text in some of the texteditors etc etc, when a particular process being processed in the background.

Is there a way I can set a wait cursor for the entire application, and also freeze the UI for the application ?

The cleanest way to do it is just to put a big, temporary, transparent component in front of everything, and set its cursor to whatever you need it to be.

Hey Jules,

Thanks for the reply. But it still does not solve the issue…Below is the buttonclick event that I have developed for testing. Still not familiar with JUCE and its capabilities so, please let me know where I have gone wrong…

One more thing to add is that, ASSUMING that this still works, user can use the TAB key to enter values in say texteditors or click buttons using TAB key and enter keys…I dont want to use setEnabled(false), as the visual effect changes with that.

if (buttonThatWasClicked == btnTest){
	TransparentBlockingComp *pBlockComp = new TransparentBlockingComp();
	pBlockComp->setBounds(0,0,getWidth(), getHeight());
	pBlockComp->setAlwaysOnTop(true);   // Whether you do this or not, doesnt matter...
           /* This is where I would be calling an API which takes quite sometime to finish, after its completed
                I will delete this blocking component hoping that the above waitCursor will be replaced again by default mousecursor. 
                For the time being I have added an infinite while loop...
	while(1){             // remove this while loop and waitCursor appears as expected why ?????????
		int nI = 5;

           deleteAndZero(pBlockComp);  // To restore the default mouse cursor.

Ah, I see you’re not familiar with event-driven programming… You can’t just block and run a for-loop, or your app can’t process any events! Put your component in place, return, and let the app carry on. Later, remove it.

(And don’t use the delete operator! Always use ScopedPointer, object composition, etc.!!)