gpt4 book ai didi

c++ - 在 Carbon App 中将焦点设置到 Cocoa 窗口

转载 作者:行者123 更新时间:2023-11-28 03:56:49 25 4
gpt4 key购买 nike

我正在尝试在其他 Carbon 应用程序中创建一个 Cocoa 窗口(它是一个使用 AGL 的 OpenGL API。无法更改它所以不要对此发表评论)。

这是一个代码片段:

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

窗口显示,但从未给出焦点。我无法编辑任何控件,所有内容都是灰色的。

帮忙!?

我试过了

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

认为这可能是 Carbon/Cocoa 的问题,但无济于事。

最佳答案

在调用 Cocoa 方法之前是否调用了 NSApplicationLoad()

关于c++ - 在 Carbon App 中将焦点设置到 Cocoa 窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3237228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com