I have a simple NIB file where I put two NSTextFields and one subclassed NSImageView under UIWindow... I want my NSImageView be the firstResponder for key events... I have read the documentation and according to that I set my custom subbclassed NSImageView as initialFirstResponder.
But that wont work... still the text fields are focused automatically and are firstRespodners... Even when I switch the focus with Tab key, the NSImageview wont be selected so it never becomes a first responder.
How do I solve this? I wan't to listen to key events on my custom NSImageView...
I have a simple NIB file where I put two NSTextFields and one subclassed NSImageView under UIWindow... I want my NSImageView be the firstResponder for key events... I have read the documentation and according to that I set my custom subbclassed NSImageView as initialFirstResponder.
But that wont work... still the text fields are focused automatically and are firstRespodners... Even when I switch the focus with Tab key, the NSImageview wont be selected so it never becomes a first responder.
How do I solve this? I wan't to listen to key events on my custom NSImageView...
In cases like this you want to look at the reference for the class you are having a problem with. In this case, a quick look reveals that NSImageView is derived from, among others, the NSResponder class. As such, a scan of methods in NSResponder yields the following:
In cases like this you want to look at the reference for the class you are having a problem with. In this case, a quick look reveals that NSImageView is derived from, among others, the NSResponder class. As such, a scan of methods in NSResponder yields the following:
This may or may not be the answer, but I have a feeling it will.
Bart
I figure out what was the problem. The NSImageView has by default enabled "Reject initial responder". This needs to be unchecked in IB in order to set is as initalFirstResponder. And it needs to be checked as Editable in IB in order to receive events. Once I did that, it solved my problem.