Window order when switching to other application and back

I have window with its Frame property set to “Document”. The user can select a record in a listbox and then edit it in a second window, which has a Frame property of “Movable Modal”. On OS X when I switch to a different application, then back, then again to another application, the order of the windows is switched (only while they are in the background):

After opening child with ShowModal: MovableModalWindow is in front of DocumentWindow Switching to other app: MovableModalWindow is in front of DocumentWindow // correct order Switching back to my application: MovableModalWindow is in front of DocumentWindow Switching to other app: DocumentWindow is in front of MovableModalWindow // wrong order Switching back to my application: MovableModalWindow is in front of DocumentWindow Switching to other app: DocumentWindow is in front of MovableModalWindow // again wrong order Switching back to my application: MovableModalWindow is in front of DocumentWindow Switching to other app: DocumentWindow is in front of MovableModalWindow // again wrong order Switching back to my application: MovableModalWindow is in front of DocumentWindow ...

Has anybody seen that behavior? I’m running OS X 10.9, unfortunately I can’t test earlier versions of OS X.

The nature of a modal window is that it requires user action before the app can progress. As you describe, when switching back to your app, the modal window comes to the front demanding to be dealt with before proceeding. IMHO, this is exactly the behavior one should expect.

Yes, that is correct - I appreciate your answer, but it is not related to my question.

My question is: has anybody seen the behavior described, when the application is deactivated?

  • First deactivation: MovableModalWindow in front of its caller DocumentWindow, which is correct.
  • Second and following deactivations: DocumentWindow in front of MovableModalWindow, which is wrong.

I’ve had reports from my users of this happening, but can’t reproduce it myself…:frowning:

Are you using Show or ShowModal?

In some cases, .ShowModal, in orders just .Show

Try using a sheet window so that it’s attached to the document window.

Unfortunately, in most of these cases, I can’t make it a sheet window because the user needs to be able to move it around to see data behind it. I’ll definitely look at changing the others to use sheets. Thanks!

You might have ran into the same problem I did recently.

Cocoa does not handle moveable modal dialogs the same way as Carbon & Win32 (not sure about Linux). If you use Show rather than ShowModal the window order can get mixed up.

The only way I could guarantee it was to always use ShowModal. This obviously causes a problem when using modal dialogs for progress windows as the program flow doesn’t continue like it does with Show. To solve this I had to split my code so that I could use the MBS CallMethod functions to execute it after ShowModal was called (ie: a short timer).

I logged a feedback case at the time but don’t have the number to hand.