Disabled COptionMenu entries on mac Cocoa

A user interface toolkit mainly for audio plug-ins (VST, AudioUnit, etc).
Post Reply
ray
Posts: 104
Joined: Fri Sep 02, 2016 9:37 am

Disabled COptionMenu entries on mac Cocoa

Post by ray »

Hi there,

We're currently adding a preset menu to our toolbar in our video effect plugins. These plugins are hosted in Adobe AfterEffects, Premiere Pro, Photoshop and Apple Final Cut Pro X using our proprietary framework.

The GUI portion is developed using VSTGUI (v4.7) and I did not have any issues whatsoever using COptionMenu in various contexts - i.e. in both standalone nor audio plugin hosting environments.

Our implementation works fine in AfterEffects and Final Cut Pro X in which the GUI is hosted in interactive mode. This is not the case in Premiere Pro and Photoshop, though, where the GUI must be handeled in a modal dialog once the host calls into the respective selector after the user has requested to open the effect GUI.

We're creating our GUI window using the following Cocoa code:

Code: Select all

NSWindow *nswindow = [NSWindow alloc];
[nswindow initWithContentRect:windowFrame
	          styleMask:NSTitledWindowMask|NSClosableWindowMask
	          backing:NSBackingStoreBuffered
	          defer:NO];
			
[nswindow setReleasedWhenClosed:NO];
[nswindow setLevel:CGShieldingWindowLevel()];
[nswindow makeKeyAndOrderFront:nil];

Code: Select all

[nswindow contentView]
is passed to

Code: Select all

CFrame::open()
and the GUI is created in the usual fashion, e.g. the preset menu is populated using something like:

Code: Select all

COptionMenu *presetMenu = new COptionMenu(size, this, -1, hBackground, hBackgroundClicked);
preset_menu->addEntry("Preset 1");
preset_menu->addEntry("Preset 2");
...
frame->addView(preset_menu);
The GUI is serviced using the following Cocoa code:

Code: Select all

NSApplication *nsapp = [NSApplication sharedApplication];
NSModalSession *modalSession = [nsapp beginModalSessionForWindow:nswindow];

bool running = true;

while(running)
{
	// Service main loop
	[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.025f]];
	
	// Run modal session
        running = ([nsapp runModalSession:modalSession] == NSModalResponseContinue);

	frame->idle();
}
	
[nsapp endModalSession:modalSession];
The GUI is fully responsive and the preset menu can be opened. However, all the menu entries are greyed out, although none of them have been marked disabled. This only happens in the context of a modal session. I had other instances in the audio world where a very similar code context using a COptionMenu in a modal session in an activation dialog performed just fine, so it must have something to do with the application environment.

Further investigation reveals that VSTGUI_NSMenu_ValidateMenuItem in nsviewoptionmenu.mm which is responsible for en-/disabling menu items is never called.

Maybe some of the Cocoa experts can help?

Thanks.

Best,
Ray
Last edited by ray on Thu Nov 05, 2020 11:16 am, edited 1 time in total.

Arne Scheffler
Posts: 417
Joined: Mon Jun 20, 2016 7:53 am

Re: Disabled COptionMenu entries on mac Cocoa

Post by Arne Scheffler »

Hi,
this looks like that the apps (both Adobe) are stealing this message. Thus I don't think that you can fix this on your side. Recently we added internal driven menu support. You can call frame->getPlatformFrame->setGenericOptionMenu (true) to use it. Maybe that's an option for you.

Cheers,
Arne

ray
Posts: 104
Joined: Fri Sep 02, 2016 9:37 am

Re: Disabled COptionMenu entries on mac Cocoa

Post by ray »

Arne Scheffler wrote:
Wed Nov 04, 2020 12:34 pm
Hi,
this looks like that the apps (both Adobe) are stealing this message. Thus I don't think that you can fix this on your side. Recently we added internal driven menu support. You can call frame->getPlatformFrame->setGenericOptionMenu (true) to use it. Maybe that's an option for you.

Cheers,
Arne
That solved it. Thanks a lot, Arne!

Post Reply