MenuHandler oddity

macOS Catalina 2023r3.1

I have two small apps with small About … windows. In fact, I cloned the window for the second app from that of the first - just changed its title and the splash image.

What’s odd is how I am allowed to invoke them. The apps’ menu items are set up identically, the menu items are both on the Helpmenu and with a Super of DesktopApplicationMenuItem and appear nicely in the application menu at run time.

But the Menu Handler methods have to contain different code. The earlier one has this:

AboutMyApp.Show ()
Return True

But if I put the equivalent code in the Menu handler for the other app, I get:

Error: static reference to instance method: call this on an instance of class DesktopWindow

and instead I require this code:

Var  w As new AboutMyApp
w.Show ()
Return True

But both are implicit instances and BBEdit, which I used to cxompare the two .xojo_window files, tells me they are identical apart from window name and title. So what have I overlooked?

That would only work if the Window (AboveMyApp) had ImplicitInstance turned on. Did you perhaps turn that off? I would recommend turning it off an instantiating the window yourself.

Both are implicit instances as I mentioned in the final para of my post.

I don’t suppose you’ve hit a reserved word with the new window?

Good question. I’ll check.

Found it. The name of the window was the same as that of the item on the MainMenuBar. So I changed the latter and also the name of the Menu Handler method. Seems the two menu-related items can have the same name.

So your suggestion, while not it, was close enough to make me look that the names, which I hadn’t thought to do before. So thanks for that.

1 Like

Interesting, I usually prefix my items with a type. winSomeName, mnuSomeName etc. avoids clashes.

1 Like