【发布时间】:2015-10-25 17:18:45
【问题描述】:
一个在 windows 上的 firefox 中运行良好的插件现在正在移植到 Mac 上的 safari。我们正在使用 Xcode 进行开发。我们希望在 Safari 浏览器中有一个可以显示视频的窗口。我阅读了有关 NPP_SetWindow 函数中使用的 NSwindow 的代码如下:
NPError NPP_SetWindow(NPP instance, NPWindow* npWindow)
{
// Get a Cocoa window reference of the browser window
NP_CGContext* npContext = (NP_CGContext*)npWindow->window;
WindowRef window = npContext->window;
NSWindow* browserWindow = [[[NSWindow alloc] initWithWindowRef:window] autorelease];
// Get a Cocoa reference of my carbon window
// yourCarbonWindow should be replaced with the window handle of the carbon
// window that should be tied to the Safari window.
NSWindow* myWindow = [[[NSWindow alloc] initWithWindowRef:yourCarbonWindow] autorelease];
// Now create a parent child relationship
[browserWindow addChildWindow:myWindow ordered:NSWindowAbove];
}
但问题是 npWindow->window 没有任何价值。用 printf 检查时,显示 0 值,表示未初始化或为 NULL。
但在 Firefox 中它具有一定的价值。 有人可以告诉如何在 Safari 中获取 NSWindow 或者问题出在哪里?还有这个碳窗是什么概念?
【问题讨论】:
标签: xcode safari osx-yosemite nswindow npapi