我正在尝试将触摸板支持与SDL应用程序集成。如何从NSWindow对象创建NSTouchBar?
我已经进入了SDL中的目标C代码,并直接进入SDLView代码并获得了工作触摸条,但现在我想要获得与SDL2库相同的功能。 SDL公开了它创建的NSWindow对象,我认为我可以创建一个使用makeTouchBar和makeItemForIdentifier实现的响应器对象,但我不知道如何将它“附加”到窗口。我认为这将是一个“响应者链”,但我并不真正知道这意味着什么或如何去做。
我试着创建以下并尝试了窗口上的setNextResponder的几个不同的组合,但似乎无法弄清楚正确的组合,以获得makeTouchBar调用,但我在正确的球场,因为它的工作原理当我将这些方法直接放在视图上时。
@interface MyTouchbarResponder : NSResponder
- (id)init;
@property(strong, readonly) NSTouchBar *touchBar;
- (NSTouchBar *)makeTouchBar;
- (nullable NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier;
@end
@implementation MyTouchbarResponder
- (id)init
{
[super init];
}
- (NSTouchBar *)makeTouchBar
{
...stuff...
}
- (nullable NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
{
...stuff...
}
@end
谢谢。
感谢。我无法控制窗口或视图类。 https://github.com/spurious/SDL-mirror/blob/master/src/video/cocoa/SDL_cocoawindow.m#L56我得到的只是NSWindow对象的句柄。 – xaxxon