Choosing focused window by code

I’m porting an application to OSX and I’m stuck in a situation I can not solve.

In fact I don’t even know if this is the normal behaviour in OSX:
I have a full screen window with a big OpenGLSurface control. When I touch a button, a new floating small window appears and the OpenGLSurface control changes the mouse cursor. You should see it by moving the cursor around the screen: on both windows: the main one and the new small floating one.
This works without any problem on Windows, but when I port the application to OSX I have not found a way to do it automatically by code. I have to click anywhere on the main window if I want to have the mouse cursor updated. The thing is that the small floating window has the focus and I can not give the focus by code to the main one.

Have you any comment or suggestion?
Thanks,

I’ve had issues in Cocoa when changing the mouse cursor didn’t work. Xojo changed the cursor back when ever I changed it. I had to use a timer with a small period and the MBS plugin to make this work.

Windows and Mac have different ways of managing the cursor.

If I understand what you want to do, is to have the updated cursor appear when the mouse hovers over the inactive full screen window ?

Technically, when the floating window is displayed, since the full screen window does not have the focus, whatever is out of the floating window belongs to the system, with its default mouse cursor. When you click, you give in fact focus to the full screen window so at that point it owns the cursor.

There is an idea, but am not sure you will want to go through it : instead of a floating window, display a canvas containing the picture of a floating window. Since everything will still belong to the full screen window, the cursor will be updated immediately. You also need a full screen transparent canvas under the false window where you return true in the mousedown event to prevent the user to access controls on the full screen window.

Then when you close the false screen, all you have to do is render it invisible together with the full screen barrier canvas.

Note that the false window being a canvas, you can place controls on it just as you would do a window. It will not be resizeable. It is not moveable either without extra effort, but at least the move should be pretty simple to do.

Thanks Beatrix and Michel for your explanations. So if [quote=158847:@Michel Bujardet] When you click, you give in fact focus to the full screen window so at that point it owns the cursor.[/quote]

The question is: Is there a way to setfocus on another window by code? Or simulate the mouse click (even using declares)?

I use Window.Show. But in a quick test that wasn’t wholly sufficient, instead, after showing the floating window start short period Timer (used 100, don’t know how low it can go) and in the Timers action call Show on the main window. Cursor continues to work until single clicking on the floating windows titlebar :frowning:

Thanks Will, it works great!!!
I’ve put a timer on the floating window.
The timer fires at the Open event and at the MouseExit event. With this second firing it doesn’t matter if you pressed anything in the floating window.

In the action of the timer:

MainWindow.Show
MianWindow.Focus = Nil