StandardKeyBinding.dict and private API
9 August 2008 11:32 am UTC
Evidently this is not a problem for most developers, but I have run into a snag caused by AppKit’s failure to declare methods that are specified in /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict.
StandardKeyBinding.dict maps keys and key combinations to specified action methods. For example, the pageUp key is mapped to scrollPageUp:. In turn, NSResponder declares the scrollPageUp: method.
However, several common and useful key bindings are mapped to selectors that are implemented in private API. For example, the home key is mapped to scrollToBeginningOfDocument:, which is not declared in any public header.
This has to be an oversight, yes? NSResponder declares but does not implement those methods so that developers can override or invoke them. And just as we sometimes need to override scrollPageUp:, we sometimes need to override scrollToBeginningOfDocument:. We can’t, though, because scrollToBeginningOfDocument: is private. Dang.
NSTextView responds to these selectors, all of which are specified in StandardKeyBinding.dict, and none of which are public:
moveToBeginningOfLineAndModifySelection:
moveToEndOfLineAndModifySelection:
moveToBeginningOfParagraphAndModifySelection :
moveToEndOfParagraphAndModifySelection :
moveParagraphBackwardAndModifySelection:
moveParagraphForwardAndModifySelection:
moveToBeginningOfDocumentAndModifySelection:
moveToEndOfDocumentAndModifySelection:
pageUpAndModifySelection:
pageDownAndModifySelection:
scrollToBeginningOfDocument:
scrollToEndOfDocument:
I filed a bug on this. In the meantime I think I have found a situation in which it truly is acceptable to invoke a private method, because those methods, having been publicized in StandardKeyBinding.dict, are not truly private. Maybe semi-private?
Leave a Comment
There are no comments for this article.