Madcap Undo Menu-Multiple MenuBar Mayhem?

I’ve been adding undo to some old codes and hit something odd that appears to be a bug in Xojo.

The setup is that I have two windows, each uses a unique menu bar. I want the Undo menu item to show the operation being undone. When I first open the second window and do something in that window, I don’t see the operation reflected in the Edit>Undo menu text–it shows the last thing from elsewhere. But if I return to the first window, I see that I can undo that second window operation. If I now return to the second window that second window operation now shows up in the edit menu! This does not happen if the windows share the same MenuBar, so it feel like some strange thing associated with multiple menu bars.

I have made a simple example (download here, 9k) should anybody want to look at this and see if it shows up at their end. It explains itself in the main window.

A workaround (other than leaving Undo generic) would be welcome. As it is right now, my users might be puzzled when their attempt to undo something undoes something else…

Since the problem resolves once the user clicks on the first window and then returns to the second window, I tried forcing this in code with .show commands, and while I can confirm that the activate events are hit for each window, this doesn’t correct the problem in the edit menu. Maybe has a connection to case 49821 where an unactivated Undo menu item cannot have its text changed. Wonder if the solution to an early problem with Cocoa versions not changing menubar properly (resolved case 15281), left this problem hanging. Don’t see this in the bug database and since I have a simple code showing the problem, will create a new case.

Workaround: If I flash a modal window (I used 100 ms) after opening the second window, all is well. That seems to trip whatever switch isn’t getting flipped when opening the window normally. Kind of a stupid fix (and probably some users will be baffled why there is this brief flash) but this gets me moving forward. Meantime this is case 52633 at Xojo.