pub unsafe trait NSObjectIMKServerInput:
ClassType
+ Sized
+ Sealed {
// Provided methods
unsafe fn inputText_key_modifiers_client(
&self,
string: Option<&NSString>,
key_code: NSInteger,
flags: NSUInteger,
sender: Option<&AnyObject>,
) -> bool { ... }
unsafe fn inputText_client(
&self,
string: Option<&NSString>,
sender: Option<&AnyObject>,
) -> bool { ... }
unsafe fn handleEvent_client(
&self,
event: Option<&NSEvent>,
sender: Option<&AnyObject>,
) -> bool { ... }
unsafe fn didCommandBySelector_client(
&self,
a_selector: Option<Sel>,
sender: Option<&AnyObject>,
) -> bool { ... }
unsafe fn composedString(
&self,
sender: Option<&AnyObject>,
) -> Option<Retained<AnyObject>> { ... }
unsafe fn originalString(
&self,
sender: Option<&AnyObject>,
) -> Option<Retained<NSAttributedString>> { ... }
unsafe fn commitComposition(&self, sender: Option<&AnyObject>) { ... }
unsafe fn candidates(
&self,
sender: Option<&AnyObject>,
) -> Option<Retained<NSArray>> { ... }
}
IMKInputController
only.Expand description
Category “IMKServerInput” on NSObject
.
Informal protocol which is used to send user events to an input method.
This is not a formal protocol by choice. The reason for that is that there are three ways to receive events here. An input method should choose one of those ways and implement the appropriate methods.
Here are the three approaches:
-
Support keybinding. In this approach the system takes each keydown and trys to map the keydown to an action method that the input method has implemented. If an action is found the system calls didCommandBySelector:client:. If no action method is found inputText:client: is called. An input method choosing this approach should implement -(BOOL)inputText:(NSString*)string client:(id)sender; -(BOOL)didCommandBySelector:(SEL)aSelector client:(id)sender;
-
Receive all key events without the keybinding, but do “unpack” the relevant text data. Key events are broken down into the Unicodes, the key code that generated them, and modifier flags. This data is then sent to the input method’s inputText:key:modifiers:client: method. For this approach implement: -(BOOL)inputText:(NSString*)string key:(NSInteger)keyCode modifiers:(NSUInteger)flags client:(id)sender;
-
Receive events directly from the Text Services Manager as NSEvent objects. For this approach implement: -(BOOL)handleEvent:(NSEvent*)event client:(id)sender;
Provided Methods§
Sourceunsafe fn inputText_key_modifiers_client(
&self,
string: Option<&NSString>,
key_code: NSInteger,
flags: NSUInteger,
sender: Option<&AnyObject>,
) -> bool
unsafe fn inputText_key_modifiers_client( &self, string: Option<&NSString>, key_code: NSInteger, flags: NSUInteger, sender: Option<&AnyObject>, ) -> bool
Receive the Unicodes, the key code that generated them and modifier flags.
Input methods implementing this method should return YES if the input was excepted, and NO if not excepted.
Sourceunsafe fn inputText_client(
&self,
string: Option<&NSString>,
sender: Option<&AnyObject>,
) -> bool
unsafe fn inputText_client( &self, string: Option<&NSString>, sender: Option<&AnyObject>, ) -> bool
Each keydown that does not map to an action method is delivered to the input method as an NSString.
If the input string is not excepted the input method should return NO. When text is accepted return YES. Input methods should implement this method when they are using keybinding (i.e. have implemented didCommandBySelector:client:).
Sourceunsafe fn handleEvent_client(
&self,
event: Option<&NSEvent>,
sender: Option<&AnyObject>,
) -> bool
Available on crate feature objc2-app-kit
only.
unsafe fn handleEvent_client( &self, event: Option<&NSEvent>, sender: Option<&AnyObject>, ) -> bool
objc2-app-kit
only.Receive all keydown and mouse events as an NSEvent (i.e. the event is simply forwarded onto the input method).
Return YES if the event was handled. NO if not handled.
Sourceunsafe fn didCommandBySelector_client(
&self,
a_selector: Option<Sel>,
sender: Option<&AnyObject>,
) -> bool
unsafe fn didCommandBySelector_client( &self, a_selector: Option<Sel>, sender: Option<&AnyObject>, ) -> bool
Called when system binds a keyDown event to an action method.
This method is designed to return YES if the command is handled and NO if the command is not handled. It is called to process a command that was generated by user action such as typing certain keys or mousing down. It is necessary for this method to return YES or NO so the event can be passed through to the client if it is not handled. The selector can be an action specified in the input method’s dictionary of keys and actions (i.e. an action specific to the input method) or one of the NSResponder action methods such as insertNewline: or deleteBackward:. By definition such action methods do not return a value. For that reason if you implement this method you should test if it is appropriate to call the action method before calling it since calling the action method is agreeing to handle the command
For example. Suppose you have implemented a version of insertNewline: that terminates the conversion session and sends the fully converted text to the client. However, if you conversion buffer is empty you want the application to receive the return key that triggered the call to insertNewline:. In that case when didCommandBySelector:client: is called you should test your buffer before calling your implementation of insertNewline:. If the buffer is empty you would return NO indicating that the return key should be passed on to the application. If the buffer is not empty you would call insertNewline: and then return YES as the result of didCommandBySelector:client:.
Sourceunsafe fn composedString(
&self,
sender: Option<&AnyObject>,
) -> Option<Retained<AnyObject>>
unsafe fn composedString( &self, sender: Option<&AnyObject>, ) -> Option<Retained<AnyObject>>
Return the current composed string. This may be an NSString or NSAttributedString.
A composed string refers to the buffer that an input method typically maintains to mirror the text contained in the active inline area. It is called the composed string to reflect the fact that the input method composed the string by converting the characters input by the user. In addition, using the term composed string makes it easier to differentiate between an input method’s buffer and the text in the active inline area that the user sees. The returned object should be an autoreleased object.
Sourceunsafe fn originalString(
&self,
sender: Option<&AnyObject>,
) -> Option<Retained<NSAttributedString>>
unsafe fn originalString( &self, sender: Option<&AnyObject>, ) -> Option<Retained<NSAttributedString>>
Return the a string consisting of the original pre-composition unicodes.
If an input method stores the original input text it should return that text here. The return value is an attributed string so that input method’s can potentially restore changes they may have made to the font, etc. The returned object should be an autoreleased object.
Sourceunsafe fn commitComposition(&self, sender: Option<&AnyObject>)
unsafe fn commitComposition(&self, sender: Option<&AnyObject>)
Called to inform the controller that the composition should be committed.
If an input method implements this method it will be called when the client wishes to end the composition session immediately. A typical response would be to call the client’s insertText method and then clean up any per-session buffers and variables. After receiving this message an input method should consider the given composition session finished.
Sourceunsafe fn candidates(
&self,
sender: Option<&AnyObject>,
) -> Option<Retained<NSArray>>
unsafe fn candidates( &self, sender: Option<&AnyObject>, ) -> Option<Retained<NSArray>>
Called to get an array of candidates.
An input method would look up its currently composed string and return a list of candidate strings that that string might map to. The returned NSArray should be an autoreleased object.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.