我試圖在其他Carbon應用程序內創建可可窗口(這是使用AGL的OpenGL API,無法更改,因此請勿對此進行評論)。將焦點設置爲Carbon應用程序中的可可窗口
這裏有一個代碼片段:
WindowRef winref = static_cast<eq::AGLWindow*>(getOSWindow())->getCarbonWindow();
vc = [[SFAttachedViewController alloc] initWithConfig:config]; //loads from view nib
NSPoint buttonPoint = NSMakePoint(event.pointerButtonPress.x + [cocoaWrap frame].origin.x, [cocoaWrap frame].size.height - event.pointerButtonPress.y + [cocoaWrap frame].origin.y);
MAAttachedWindow *attachedWindow = [[MAAttachedWindow alloc] initWithView:[vc view] attachedToPoint:buttonPoint onSide:side atDistance:0.0f]; // some Matt Gemmell goodness!
我嘗試用以下行之一,以顯示它:
// A)
[NSApp runModalForWindow:[attachedWindow retain]]; // makes a white box
// B)
NSWindow *cocoaWrap = [[NSWindow alloc] initWithWindowRef:winref];
[cocoaWrap addChildWindow:attachedWindow ordered:NSWindowAbove];
// C)
[attachedWindow makeKeyAndOrderFront:NSApp];
窗口顯示,但重點是從來沒有放棄。我無法編輯任何控件,並且一切都變灰。
help!?
我試圖
HIViewRef viewRef;
HICocoaViewCreate([vc view], 0, &viewRef);
WindowRef attachedRef = (WindowRef)[attachedWindow windowRef];
SetKeyboardFocus(attachedRef, viewRef, kControlNoPart);
想這可能是一個碳/可可的事情,但無濟於事。
你看過這個PDF嗎? http://developer.apple.com/legacy/mac/library/documentation/Cocoa/Conceptual/CarbonCocoaDoc/CarbonCocoaIntegration.pdf – JeremyP 2010-07-13 15:37:04
是的,這就是爲什麼我在我的窗口init()方法中調用了NSApplicationLoad()調用,而不是在主線程。 – 2010-07-13 18:46:15