代码之家  ›  专栏  ›  技术社区  ›  Stephen Furlani

在Carbon应用程序中将焦点设置为可可色窗口

  •  0
  • Stephen Furlani  · 技术社区  · 15 年前

    我试图在一个Carbon应用程序中创建一个Cocoa窗口(这是一个使用AGL的openglapi)。无法更改,所以不要对此发表评论)。

    下面是一个代码片段:

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

    认为这可能是碳/可可的事情,但没有用。

    1 回复  |  直到 15 年前
        1
  •  2
  •   Yuji    15 年前

    你打电话了吗 NSApplicationLoad()

    推荐文章