Before folk run screaming NDA, this may not be an Avid/Digi problem. Their host passes me a pointer to an NSView, and I work with that - this is so utterly obvious that no amount of NDA can get around it. I won't be posting any of their SDK/internals.
So..
We have a synth object which is wrapped for VST, AU, standalone, and AAX. (There's RTAS as well, but that uses Carbon). When any of them want a UI, the wrapper gets the pointer and it's marshalled to the UI generation code with a objwrapper->OpenEditor((void*)mHost_NSView);
My OpenEditor code:
Code: Select all
bool VSTEditor::OpenEditor ( void* inPtr /* system window */)
{
AEffEditor::open(inPtr); //Yes, yes, I subclassed VST.. it's just easier!
gfl::GFLSize theSize ( 640, 480 );
gfl::gPoint origin;
gfl::Rectangle theRect ( origin, theSize );
/*
>>>> Code to read UI details via LUA removed
*/
theSize = mMainView->GetRect().size;
mRect.left = 0;
mRect.top = 0;
mRect.bottom = theSize.height;
mRect.right = theSize.width;
#ifdef MAC_Code
@autoreleasepool {
try{
mGFRootView = new gfl::MacCocoaView ( mMainView->GetRect(), MacCocoaView::AAX );
if([(id)inPtr isKindOfClass:[NSWindow class]]){
NSWindow* theWindow = static_cast<NSWindow*>(inPtr);
NSView* contentView = theWindow.contentView;
mGFRootView->AddTo ( contentView );
}else if([(id)inPtr isKindOfClass:[NSView class]]){
NSView* contentView = static_cast<NSView*>(inPtr);
mGFRootView->AddTo ( contentView );
}else{
#ifndef __LP64__
//32bit Cocoa/Carbon code removed, not relevant here
#endif
}
mMainView->SetParent(mGFRootView);
mGFRootView->AddView(mMainView);
}catch ( gfl::Exception e ) {
DBG("Caught exception loading ui...\n");
return false;
}
}
#endif //MAC_Code
return true;
}
I have found that overriding -acceptsFirstMouse to return YES on my UI window class means I get the UI working first time; but if I click on the desktop then back to the UI it doesn't respond unless I click the hosting UI container window to give it focus, then all works again.
Does this make sense to anyone? Has anyone encountered something like this before? What should I be looking for? I'm guessing it's something fairly rudimentary that my knowledge of OSX is lacking..!
Thanks
DSP