How do I invoke an @IBAction on an NSViewController wrapped in NSViewControllerRepresentable?

How do I invoke an @IBAction on an NSViewController subclass wrapped in NSViewControllerRepresentable?

I can’t see a way to specify some .commands {} in my DocumentGroup that eventually call @IBAction methods in my wrapped view controller.

Hello, You should go to the SwiftUI section because it seems to me that your question is more appropriate there than in OS X.
Regards!!
Rafael

Huh, I thought I had put it in SwiftUI. In any case, the answer turns out to be a bit of a hack (IMHO): you have to call NSApp.sendAction from the Command, and send the action to nil, which sends it up the NSResponder chain. No way I can find to target a specific instance, but that’s not too much of an issue for me. What doesn’t seem to work is the enabling/disabling of menu commands.

This topic was automatically closed after 166 days. New replies are no longer allowed.