1
私はたくさんの質問を見ましたが、何か助けになるものは見つかりませんでした。私は多くのApple開発者のページを見てきましたが、私はそれらが少し不明であることがわかりました。CocoaとObjective-C++を使ってNSWindowにイベントを追加する
Objective-C++でXcodeや他のIDEを使わずにアプリケーションを作って、すべての作業をしたいと思っています。私のIDEはAtomで、g ++でコンパイルします。私は、ウィンドウを作成するには、以下のクラスを持っている:私は理解してなかった何から
//Window.mm
#ifndef WINDOW_H
#define WINDOW_H
#import "Cocoa/Cocoa.h"
class Window
{
private: NSWindow* window;
public: Window(const char* title, int x, int y, int w, int h, NSColor* bg = [NSColor colorWithCalibratedRed:0.3f green:0.3f blue:0.3f alpha:1.0f])
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
NSRect frame = NSMakeRect(x, y, w, h);
NSUInteger windowStyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable;
NSRect rect = [NSWindow contentRectForFrameRect:frame styleMask:windowStyle];
this->window = [[[NSWindow alloc] initWithContentRect:rect styleMask:windowStyle backing:NSBackingStoreBuffered defer:NO] autorelease];
[this->window makeKeyAndOrderFront: this->window];
[this->window setBackgroundColor: bg];
[this->window setTitle: [NSString stringWithUTF8String:title]];
[this->window orderFrontRegardless];
[pool drain];
[NSApp run];
}
};
#endif
は、私がNSViewのと何かをする必要があるということですが、私は私が行うことになってるのかわからないんだけど。ウィンドウからキー入力を取得するにはどうすればいいですか?あなたは、たとえば、キー入力イベントを受け取るためにNSWindowのをサブクラス化する必要が