osx 和 objc - 为插件运行第二个运行循环?
这里是C程序员。我正在尝试为正在运行的 OSX 应用程序创建一个插件,打开它自己的窗口,接受按钮按下,关闭窗口并返回到插件 - 而不是退出应用程序。
我已经能够使用 NSApp 打开一个窗口,甚至在其中有一个按钮,但它不会执行任何操作。
[button setTarget: nil];
[button setAction: @selector(fauxAction:)];
我就是这样设置的。通常,您[按钮 setTarget: self],但是,这是在普通的 c 函数内部,并且没有“self”。我不知道如何从 c 调用 objc 方法,如果这是我需要解决的问题。我只想在按下按钮时调用方法 fauxAction 。
这是插件的窗口——而不是主应用程序。我不能让他们越过电线。 [NSApp run] 并将退出菜单放在上面会退出主应用程序,我猜是因为运行循环包装了执行线程。
任何帮助将不胜感激。我感觉自己快要淹死在这里了。
C programmer here. I'm trying to make a plugin to a running OSX app open its own window, accept a button press, close the window and come back to the plugin - not quit the app.
I've been able to get a window open using NSApp, and I've even got a button in it, but it won't DO anything.
[button setTarget: nil];
[button setAction: @selector(fauxAction:)];
Is how I set it up. Normally, you [button setTarget: self], BUT, this is inside a normal c function, and there is no "self." I don't know how to call an objc method from c, if that's the problem I need to solve. I just want the method fauxAction to be called when the button is pressed.
This is the plugin's window -- not the main application. I can't have them crossing wires. [NSApp run] and putting the quit menu on it quits the main application, I guess because the run loop wraps the executing thread.
Any help would be appreciated. I feel like I'm drowning here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我明白了 - NSApp runModalForWindow。它只运行窗口循环,而主循环不受干扰。
I got it - NSApp runModalForWindow. That runs just the window loop, leaves the main loop unmolested.