Disable mouse movements in Window/Canvas?

Hello Everyone,

How can I disable mouse movements and pausing in the window when the mouse clicks on the window when drawing in a Canvas? This does not happen on Mac and happens on Windows with a Canvas and OpenGL. Below is a screen grab of an example animation where a circle is drawn on a canvas.

I have been able to increase the drawing rate to 90 frames-per-second and higher, as long as the mouse does not enter the canvas. I have used a tight loop that is commonly performed in programs that I write in C++ and would like to know how to stop mouse movements from interfering with drawing. My wild guess (thats all it is) is that #Pragma DisableAutoWaitCursor would fix the problem, and this has been deprecated Pragma Directives.

When I program the same simple program in C++, by placing the reading of mouse movement in the incorrect place, I can get the same stuttering of graphics that is shown in the below Xojo program.

Draw Animation

I am trying to make something more cross-platform, and am trying to develop a work-around on Windows Xojo first. This has been a long-standing problem when drawing on Xojo, and am curious if anyone has been able to figure out a solution :slight_smile:

When the example program runs on its own, the frames per second is 90 fps. When a mouse is moved in the window, every mouse movement delays drawing.

Using a timer is not an option, as the time has a maximum resolution at about 15 ms.

Something else I forgot to mention. When the window top (header?) has the mouse over it and then the mouse button held down, all animation stops until the mouse button has been released. This also happens with OpenGL on Windows. This does not happen on Mac.

Again, I can make this happen in C++ by placing mouse code in the wrong place with GetMessage action event loop in C++ or with Delcares in Xojo (See Chapter 21 of Xojo Delcares Book) :slight_smile:

+1

As I’m sure you’re aware, its seems like the framework’s time to process events that is causing the pauses.

Declare Function EnableWindow Lib "User32" (hWnd As Integer, bEnable As Int32) As Int32 Call EnableWindow(Self.Handle, 0)

Will stop all mouse and keyboard events reaching the window.

You can still read things like system.mousex + mousey + mousedown so you can calculate when you are clicking over the window and handle it inside your tight loop. You could also use this to re-enable the window if you move the mouse near the titlebar, however the stuttering would re-appear then.

Hi Julian,

Thanks for the helpful answers, and as you mentioned I also suspect the framework is causing the pauses. I had a little bit of hope that there was some unknown obscure command that could be used to bypass part of the framework :slight_smile:

I’ll try your suggestion and if I am still running into issues then I will likely need to dust off the Plugin Book and make a plugin to bypass the framework.

Thanks for your comment. :slight_smile: