Window.SetFocus

XOJO 2022r1 - Windows 10
In my app I have several BevelButtons to open different windows.
When more than one window is opened, moving over the bevelbuttons with the mouse sets the corresponding window in focus.
This has always worked perfect, but after convertion to API2 it doesn’t work anymore.

The code for doing this recides in the ‘MouseEnter’ event of each BevelButton.
Each window has a flag that is set to true when the corresponding window is opened. (windowXOpened, windowYOpened and windowZOpened).
Think of 3 Bevelbuttons opening WindowX, windowY and windowZ.
In the MouseEnter event the corresponding code looks like ;
BevelButton MouseEnter event for WindowX

If windowXOpened Then
  windowX.SetFocus
End If

BevelButton MouseEnter event for WindowY

If windowYOpened Then
  windowY.SetFocus
End If

BevelButton MouseEnter event for WindowZ

If windowZOpened Then
  windowZ.SetFocus
End If

What could be the solution for making this work again ?

Thanks
Regards

By not work, do you mean that the window isn’t coming to the front? Perhaps using window.Show instead of .SetFocus?

1 Like

Thanks for the reply.
Yes indeed, the window is not coming to the front.

I tried it with Window.Show and that makes the window coming to the front when MouseEnter over the BevelButton → OK.

Will do some tests to see if that doesn’t create other issues.

Thanks
Regards

Explanation attemp; the documentation says:

Window.SetFocus()

Supported for all project types and targets.

Removes the focus from the control that currently has the focus, leaving no control with the focus.

So, it worked because you were accessing the window, not because of .SetFocus.