Controlling the mouse pointer
I have a script that implements some UI elements, and some button clicks perform slightly long-running tasks. I want to be able to change the mouse pointer to the wait cursor while tasks are running but UserQuery doesn't have a Cursor property. Is there a way to do it?
Comments
I would set cursor for the whole page (Results to Rich Text mode).
Under Windows you can play with application cursor. I wouldn't recommend that though.
Ctrl
+F1
and search for progress.I tried the code below but it isn't working. When the button is clicked it displays the following but the mousepointer stays as the default arrow pointer throughout. The fact that the initial state of Current is WaitCursor seems odd.
In real WinForms
System.Threading.Thread.Sleep(1000);
blocks event loop, so cursor wouldn't be changed.I could be completely wrong, but I suspect the reason this does not work is because your query is run as a separate progress which does not have an application form or its own UI (or cursor), but uses some 'magic' to send the results to the application form in LinqPad.
For example if you dump
System.Windows.Forms.Application.OpenForms
from your query you will see that it has no results.If you create your own Windows.Form in your query and add a standard windows button the WaitCursor class would work correctly.
If I am correct then, to do want you want, you may need to ask Joe if he can add some command (like Util.SetCursor) that will allow your query to send a request to the main Linqpad UI to change it's cursor.
P.S. When I have wanted to do something like this, I have taken a completely different approach :
Either change the text of the button during the operation. .e.g.
or if I want to make it completely obviously, add a huge header at the start, e.g.
(Note there does seem to be a tiny glitch with the later example where the banner shrinks but does not completely disappear)
Thanks for the replies. I had hoped it would be simple to do but as it isn't and the script is for my own use I'll just live with knowing that sometimes the task after button click takes longer than others.