Inherits from | |
Conforms to | |
Framework | System/Library/Frameworks/InputMethodKit.framework |
Availability | Available in Mac OS X v10.5 and later. |
Declared in | IMKInputController.h |
Related sample code |
The IMKInputController
class provides a base class for custom input controller classes. The IMKServer
class, which is allocated in the main function of an input method, creates an input controller object for each input session created by a client application. For every input session there is a corresponding IMKInputController
object.
An IMKInputController
object controls text input on the input method side. It manages events and text from the applications and converted text from the input method engine. IMKInputController
implements fully the IMKStateSetting
and IMKMouseHandling
protocols. Typically you do not need to override this class, but you do need to provide a delegate object that implements the methods that your are interested in. The IMKInputController
versions of the protocol methods check whether the delegate object implements a method, and calls the delegate version if it exists.
Sends the selected candidate string and annotation string to the input controller.
- (void)annotationSelected:(NSAttributedString*)annotationString forCandidate:(NSAttributedString*)candidateString
The annotation string associated with the candidate.
The candidate string that the user moved to.
This method is called when the user moves to a candidate.
IMKInputController.h
Stops the current composition and replaces marked text with the original text.
- (void)cancelComposition
This method calls the method originalString:
to obtain the original text and sends that text to the client using a call to the IMKTextInput
protocol method insertText:replacementRange:
IMKInputController.h
Informs an input controller that a new candidate is selected.
- (void)candidateSelected:(NSAttributedString*)candidateString
The changed candidate string.
The candidate object is the user’s final choice from the candidate window. The candidate window is closed before this method is called.
IMKInputController.h
Informs an input controller that the current candidate selection in the candidate window has changed.
- (void)candidateSelectionChanged:(NSAttributedString*)candidateString
The changed candidate string.
Note this method is called to indicate user activity in the candidate window. The candidate object might not be the user’s final selection.
IMKInputController.h
Returns the client object associated with the input controller.
- (<IMKTextInput, NSObject>))client
The client object. The returned object is an autoreleased object.
The client object conforms to the IMKTextInput
protocol.
IMKInputController.h
Returns a dictionary of text attributes.
- (NSMutableDictionary*) compositionAttributesAtRange:(NSRange)range
The range of text whose attributes you want to obtain.
The dictionary of text attributes. The default implementation returns an empty dictionary.
IMKInputController.h
Returns the delegate for input controller object.
- (id)delegate
The delegate object. The returned object is an autoreleased object.
Passes commands that are not generated as part of the text input process.
- (void)doCommandBySelector:(SEL)aSelector commandDictionary:(NSDictionary*)infoDictionary
A selector that represents a command from the text input menu.
A dictionary that contains two key-value pairs:
kIMKCommandMenuItemName
, whose value is an NSMenuItem
object. That is, the item selected by the user.
kIMKCommandClientName
, whose value is the current client—id<IMKTextInput, NSObject>
.
The default implementation checks if the input controller object (that is, self) responds to the selector. If so, it sends the message performSelector:withObject:
to the input controller class. The object parameter in that case is the infoDictionary
parameter.
This method is called when a user selects a command from the text input menu. To support this, an input method must provide actions for each menu item that is placed in the menu. For example, (void)menuAction:(id)sender
. Note that the sender in this instance is the info dictionary.
IMKInputController.h
Informs an input method that it should close any visible user interface.
- (void)hidePalettes
IMKInputController.h
Initializes the input control by setting the delegate.
- (id)initWithServer:(IMKServer*)server delegate:(id)delegate client:(id)inputClient
The server object for the controller.
The delegate object.
The client object that will send messages to the controller using the server object. The client object must confirm to the IMKTextInput
protocol.
The initialized input controller object.
Methods in the IMKStateSetting
and IMKMouseHandling
protocols that are implemented by the delegate object always include a client parameter. Methods in the IMKInputController
class do not need to take a client because the initWithServer:delegate:client:
method stores the client object you supply as an ivar when it initializes the IMKInputController
object.
IMKInputController.h
Returns a dictionary of text attributes that can mark a range of an attributed string to send to a client.
- (NSDictionary*)markForStyle:(NSInteger)style atRange:(NSRange)range
A style, which should be one of the following values: kTSMHiliteSelectedRawText
, kTSMHiliteConvertedText
, or kTSMHiliteSelectedConvertedText
. See the AERegistry.h
header file for the definition of these values.
The range (that is, a clause) to mark.
The dictionary of text attributes. The returned object should be an autoreleased object.
This utility function can be called by input methods to mark each range (i.e. clause ) of marked text. T
The default implementation first calls the method compositionAttributesAtRange:
to obtain the additional attributes that an input method wants to include, such as font or glyph information. Then, it adds the appropriate underline and underline color information to the attributes dictionary for the style parameter. Finally it adds the style value as the dictionary value. The key for the style value is NSMarkedClauseSegmentAttributeName
.
IMKInputController.h
Returns a menu of commands that are specific to an input method.
- (NSMenu*)menu
The menu object. This object is an autoreleased object.
This method is called whenever the menu needs to be drawn so that an input method can update the menu to reflect the current state.
IMKInputController.h
Returns the range in the client document that the text should replace.
- (NSRange)replacementRange
The range to replace.
This method is called by updateComposition
to obtain the range in the client document where marked text should be placed. The default implementation returns an NSRange
object whose location and length are NSNotFound
. That indicates that the marked text should be placed at the current insertion point. Input methods that insert marked text somewhere other than at the current insertion point should override this method.
An example of an input method that might override this method would be one replaces words with synonyms. That input method would watch for certain words and when it detects such a word it would replaced the word by marked text that was a synonym of the word.
IMKInputController.h
Returns where the range of the selection that should be placed inside marked text.
- (NSRange)selectionRange
The range of the selection. This object should be an autoreleased object.
This method is called by updateComposition
to obtain the selection range for marked text. The default implementation sets the selection range at the end of the marked text. You should override this method if your input method provides font or glyph information.
IMKInputController.h
Returns the server object that manages the input controller.
- (IMKServer*)server
The server object. The returned object is an autoreleased object.
IMKInputController.h
Sets the delegate for input controller object.
- (void)setDelegate:(id)newDelegate
The delegate object to set.
IMKInputController.h
Informs the input controller that the composition has changed.
- (void)updateComposition
This method calls the protocol method composedString:
to obtain the current composition. The current composition is sent to the client by a call to the method setMarkedText:selectionRange:replacementRange:
.
IMKInputController.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-06-06)