开发者

Set Focus to a Cocoa Window in Carbon App

开发者 https://www.devze.com 2023-01-07 03:53 出处:网络
I\'mtrying to create a Cocoa Window within an otherwise Carbon Application (it\'s an OpenGL API that uses AGL.Can\'t change it so don\'t comment on that).

I'm trying to create a Cocoa Window within an otherwise Carbon Application (it's an OpenGL API that uses AGL. Can't change it so don't comment on that).

Here's a code snippit:

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!

And I try to show it with one of the following lines:

// 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];

The window shows, but the focus is never given. I can't edit any of the controls, and everything is grayed out.

help!?

I tried

HIViewRef viewRef;
HICocoaViewCreate([vc view], 0, &viewRef);
WindowRef attachedRef = (WindowRef)[attachedWindow windowRef];
SetKeyboardFocus(attachedRef, viewRef, kControlNoPart);

Thinking it might have been a Carbon/Cocoa t开发者_如何学Ching, but to no avail.


Did you call NSApplicationLoad() before calling Cocoa methods?

0

精彩评论

暂无评论...
验证码 换一张
取 消