简体   繁体   English

C++ 中的 NSButton 事件处理

[英]NSButton event handling in C++

I'm creating a thin layer of C++ on top of Cocoa widgets and there's a problem of handling NSButton events without ObjC object as a target.我在 Cocoa 小部件之上创建了一层薄薄的 C++ 并且在没有 ObjC object 作为目标的情况下处理 NSButton 事件时存在问题。

Any ideas how could I use c++ class methods to handle button click?任何想法如何使用 c++ class 方法来处理按钮点击?

For example:例如:

[button setTarget:cppObj];
[button setAction:@(cppObjMethod:)]

The code above doesn't work, of course.当然,上面的代码不起作用。

You would need to set the target and action to an Objective-c class / method which itself calls the C++ code.您需要将目标和操作设置为 Objective-c class / 方法,该方法本身调用 C++ 代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM