One workaround, using FMP Advanced, is to disable the Red X Close button(s) in the New WIndow scripstep using "Specify Advanced Styles" and replace the standard File>Close menu with a custom menu that updates your calculations and also closes the window. The user must then raise Window A before closing it with the menu or a shortcut.
Exactly how did you set this up?
On FileMaker 12.03, Windows XP, I ran the following test:
I created a script:
Show Custom Dialog [ Get ( WIndowName ) ]
I set the OnWIndowClose script trigger in FileOptions to perform that script.
I then used New Window in the Window menu to create two windows, resizing and positioning windows so that I could see both close buttons in the upper right corner.
I clicked the close button for the window in back
The custom dialog popped up showing the name of the window being closed. This shows the focus is on the correct window and any script steps that I put in place of Show Custom Dialog should run from the context of the window that is about to be closed.
That's because what I am doing is using a custom menu to trap the Close command, not using the OnWindowClose command (my script started in FileMaker 10). The trapped Close is what closes the wrong window
Now that I have played with OnWindowClose a bit, I see that this a vastly superior solution and a wlecome addition, so I will rewrite my script. Thanks!
I use the custom menu option a lot and haven't had this problem, but then I don't normally set up a situation where you would be closing the underlying file, I almost always use a second window as a modal input dialog that prevents the user from interacting with the underlying window until the first window is closed.