Hi. I’ve got a rather odd problem. The problem is about a Mac application created on a Mac using the most current Xojo 2022r31, and on the latest Mac Ventura when Stage Manager is ON.
I have a program that has a main window. If you click a button on the window, a modal dialog pops up (call it ModalDialog-1, MD1), if you press a button on MD1, a different modal dialog pops up (MD2)…when you dismiss MD2, the focus returns to MD1, and when you dismiss MD1 the focus returns to the main window. Perfect. At least, that’s how it’s worked for years on a program (programmed with an earlier version of Xojo.) And, it works the same way as it always had when I re-do the program using the latest Xojo2022r31.
But, a problem appears if I merely turn on Ventura’s Stage Manager (activating it using the Control Center icon in the MenuBar). As soon as Stage Manager becomes active, this is what happens…
In my app’s main window, click to get MD1, then click in MD1 to get MD2…(so far so good) but now if you dismiss MD2 the focus goes back to the main window (NOT MD1). The MD1 window is still on the screen and should be the active window but the active window is the main window NOT MD1. (And, if my app happens to have another (non-modal) window open, the focus might go to that window, again with MD1 still standing there without focus.) A dangerous situation.
One fix is easy. Just turn Stage Manager off. But, of course, that’s hardly a fix.
So, the question is, did I just find a bug in Ventura’s Stage Manager’s handling of windows and dialogs, or did Stage Manager just expose a bug in my own handling of windows and dialogs (that’s been with me for years!)? Might I be using Dialog windows that aren’t sanctioned anymore or some such thing? The program’s worked for a decade and more as it should, and only with Stage Manager On does it mess up. Curious, eh?
And, to add a bit more to the story, I was able to fix this issue no matter the origin of the odd behavior. I added a “MD1Window.Show” to the code after the MD2 modal dialog is dismissed. Now, the program works as it should whether Stage Manager is on or off. But, why should I have to add the Window.Show explicitly. In all times past, I never had to do that. The Mac would just automatically put the focus back to the window or dialog that called the modal dialog.
Anyway, I do have the fix, but it’s still a mystery why this is happening, and I just don’t know yet whether the problem I fixed was mine or Apple’s. Any thoughts appreciated! THANKS!