Activating a window

In my program, I open a “daughter window” alongside the main window, to show progress as data is entered. After I open that daughter window, I reactivate the main window to continue collecting data entry. At that point in my program, I pass the focus to a specific text field on the main window. That field appears to have the focus but unless I click on the window somewhere, it doesn’t come to the front and allow data entry.

In Christian’s MonkeyBread routine “ActivateWindowMBS” the same thing happens - he notes that “… some windows may not come to the front unless they are clicked on.” That appears to be my problem. Is there a workaround for this or must I have the user click on the window to get going with data entry again?

In trying things out, I have determined that if I CLOSE the daughter window the main window works as I want - but I want the daughter window to remain in place and receive updates as data entry progresses. The main window contains data I don’t want to lose when the daughter window is triggered.

While this is not an earth-shaking issue, I wondered if there is a way around this limitation. I keep trying different things but so far no luck.

I forgot to mention - MacOS Sonoma 14.6.1, MacStudio M2 Max

Have-you checked the documentation for Window, particularly, .Show ?

Yes, Emile, I have tried that, but the Window.Show does not activate a specific control which has the focus unless I use a Window.Close to shut down the other window first.

If you create a simple sample project and upload to your post (as zip), maybe someone can give you an idea if possible.

Try the good ol’ Timer approach. Call MainWindow.Show with a Timer, Period=0 is fine all we’re trying to do is belay the call until the next event loop. That might just get the re-activate to happen after the child window has finished opening.

What Type is your “daughter window”?

Because depending on the Type, it may be stealing the focus from the opener (parent) window.

1 Like

Mea Culpa, I guess. Tim Parnell suggested a Timer approach, and AlbertoD said to create a simple sample project to demonstrate the issue. I found while building a little sample that SOMETIMES the main window would actually activate with the proper control having the focus when control was returned to it. I know computers don’t do things sometimes, so I put in a [DelayMBS] statement and experimented with different times. I was able to get consistent window activation and focus to a specific control with a 0.25 second delay. Problem solved.

Thanks, guys, for making me clear my head and revisit the problem. Crisis is passed!

1 Like