MOCompletionManager


Provides generic completion facilities for NSTextViews or textual editable NSControls.
Superclass: NSObject



MOCompletionManager provides a small framework for implementing various types of escape completion. The delegate of an NSTextView or editable NSControl can use an instance of MOCompletionManager to handle escape completion merely by calling a couple of methods at appropriate times. The class manages the completion and keeps state necessary for completion but does not implement any specific style of completion. Subclasses of the abstract class MOCompletionStrategy provide the actual completion behavior.

To use MOCompletionManager just alloc/init one. Usually one instance will serve a single NSTextView or editable NSControl. You will need to create an array of completion strategies and pass it to setCompletionStrategies:. MOKit comes with one strategy: MOFilenameCompletionStrategy. You can create others by subclassing MOCompletionStrategy. Often a MOCompletionManager has a single completion strategy. If it has more than one, they are tried in order and the first one that returns possible completions in a given context is the one used. If MOCompletionManager is the delegate of an NSTextView, then everything will just work, but usually this is not possible because you have a controller object that needs to be delegate. Usually the controller object "has-a" MOCompletionManager. In this case, you just need to implement a couple of the delegate messages to call into the MOCompletionManager: -textDidChange:, -textDidEndEditing:, and -textView:doCommandBySelector:.

In the first two methods, you should call -dumpCompletionState in the MOCompletionManager. For the last one, you should call -doCompletionInTextView:startLimit:basePath: if the command selector is -complete:.

For controls, of course, the control variants of these delegate methods would be used: -controlTextDidChange:, -controlTextDidEndEditing:, and -control:textView:doCommandBySelector:.

Completion works in a standardized way. A MOCompletionStrategy object is used to generate a list of possible completions when completion is invoked for the first time in a given context. On that first completion, the longest common prefix of all the completions found is appended to the prefix string. On subsequent completions with the same context (ie no selection changes or editing in between) the actual completions are cycled through one at a time.



(Last Updated 3/20/2005)
HTML documentation generated by HeaderDoc