简体   繁体   中英

(Mac) Changing the window of an NSWindowController to a subclass of NSWindow

I'm using a NIB with IB that's unpacked into an NSWindow by my NSWindowController subclass when it's initialized (as normal). [NSWindowController* window] gives me the window of the controller.

Now, I want to make my window controller's window be of a different class that subclasses it. Specifically, I want to override one method in it, sendEvent. This doesn't work, not that I thought it would:

self.window = ((WebViewEventKillingWindow*) self.window);

WebViewEventKillingWindow is a subclass to disable user interaction (thanks to Bob, found here Disable a WebKit WebView ). I'm doubting that this is even possible to do without a different approach, but I'm fairly new to this.

Select your window in Interface Builder, and ensure that the attributes inspector is open.

The first option in that panel is "Custom Class" - type in the name of your NSWindow sublass in there:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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