objc2_input_method_kit/generated/
IMKInputController.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7use objc2_app_kit::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern "C" {
13    /// An NSMenuItem in the infoDictionary passed to menu item actions.
14    ///
15    ///
16    /// Use as a key to find the NSMenuItem in the infoDictionary.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimkcommandmenuitemname?language=objc)
19    pub static kIMKCommandMenuItemName: &'static NSString;
20}
21
22extern "C" {
23    /// A client object that conforms to the IMKInputText and NSObject protocols.
24    ///
25    ///
26    /// Use as a key to find the client in the infoDictionary.
27    ///
28    /// See also [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/kimkcommandclientname?language=objc)
29    pub static kIMKCommandClientName: &'static NSString;
30}
31
32mod private_NSObjectIMKServerInput {
33    pub trait Sealed {}
34}
35
36/// Category "IMKServerInput" on [`NSObject`].
37///
38/// Informal protocol which is used to send user events to an input method.
39///
40/// 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.
41///
42/// Here are the three approaches:
43///
44/// 1.  Support keybinding.
45/// 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
46/// -(BOOL)inputText:(NSString*)string client:(id)sender;
47/// -(BOOL)didCommandBySelector:(SEL)aSelector client:(id)sender;
48///
49/// 2. Receive all key events without the keybinding, but do "unpack" the relevant text data.
50/// 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:
51/// -(BOOL)inputText:(NSString*)string key:(NSInteger)keyCode modifiers:(NSUInteger)flags client:(id)sender;
52///
53/// 3. Receive events directly from the Text Services Manager as NSEvent objects.  For this approach implement:
54/// -(BOOL)handleEvent:(NSEvent*)event client:(id)sender;
55#[doc(alias = "IMKServerInput")]
56pub unsafe trait NSObjectIMKServerInput:
57    ClassType + Sized + private_NSObjectIMKServerInput::Sealed
58{
59    extern_methods!(
60        /// Receive the Unicodes, the key code that generated them and modifier flags.
61        ///
62        /// Input methods implementing this method should return YES if the input was excepted, and NO if not excepted.
63        ///
64        /// # Safety
65        ///
66        /// - `string` might not allow `None`.
67        /// - `sender` should be of the correct type.
68        /// - `sender` might not allow `None`.
69        #[unsafe(method(inputText:key:modifiers:client:))]
70        #[unsafe(method_family = none)]
71        unsafe fn inputText_key_modifiers_client(
72            &self,
73            string: Option<&NSString>,
74            key_code: NSInteger,
75            flags: NSUInteger,
76            sender: Option<&AnyObject>,
77        ) -> bool;
78
79        /// Each keydown that does not map to an action method is delivered to the input method as an NSString.
80        ///
81        /// 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:).
82        ///
83        /// # Safety
84        ///
85        /// - `string` might not allow `None`.
86        /// - `sender` should be of the correct type.
87        /// - `sender` might not allow `None`.
88        #[unsafe(method(inputText:client:))]
89        #[unsafe(method_family = none)]
90        unsafe fn inputText_client(
91            &self,
92            string: Option<&NSString>,
93            sender: Option<&AnyObject>,
94        ) -> bool;
95
96        #[cfg(feature = "objc2-app-kit")]
97        /// Receive all keydown and mouse events as an NSEvent (i.e. the event is simply forwarded onto the input method).
98        ///
99        /// Return YES if the event was handled. NO if not handled.
100        ///
101        /// # Safety
102        ///
103        /// - `event` might not allow `None`.
104        /// - `sender` should be of the correct type.
105        /// - `sender` might not allow `None`.
106        #[unsafe(method(handleEvent:client:))]
107        #[unsafe(method_family = none)]
108        unsafe fn handleEvent_client(
109            &self,
110            event: Option<&NSEvent>,
111            sender: Option<&AnyObject>,
112        ) -> bool;
113
114        /// Called when system binds a keyDown event to an action method.
115        ///
116        /// 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
117        ///
118        /// 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:.
119        ///
120        /// # Safety
121        ///
122        /// - `a_selector` must be a valid selector.
123        /// - `sender` should be of the correct type.
124        /// - `sender` might not allow `None`.
125        #[unsafe(method(didCommandBySelector:client:))]
126        #[unsafe(method_family = none)]
127        unsafe fn didCommandBySelector_client(
128            &self,
129            a_selector: Option<Sel>,
130            sender: Option<&AnyObject>,
131        ) -> bool;
132
133        /// Return the current composed string.  This may be an NSString or NSAttributedString.
134        ///
135        /// 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.
136        ///
137        /// # Safety
138        ///
139        /// - `sender` should be of the correct type.
140        /// - `sender` might not allow `None`.
141        #[unsafe(method(composedString:))]
142        #[unsafe(method_family = none)]
143        unsafe fn composedString(&self, sender: Option<&AnyObject>) -> Option<Retained<AnyObject>>;
144
145        /// Return the a string consisting of the original pre-composition unicodes.
146        ///
147        /// 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.
148        ///
149        /// # Safety
150        ///
151        /// - `sender` should be of the correct type.
152        /// - `sender` might not allow `None`.
153        #[unsafe(method(originalString:))]
154        #[unsafe(method_family = none)]
155        unsafe fn originalString(
156            &self,
157            sender: Option<&AnyObject>,
158        ) -> Option<Retained<NSAttributedString>>;
159
160        /// Called to inform the controller that the composition should be committed.
161        ///
162        /// 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.
163        ///
164        /// # Safety
165        ///
166        /// - `sender` should be of the correct type.
167        /// - `sender` might not allow `None`.
168        #[unsafe(method(commitComposition:))]
169        #[unsafe(method_family = none)]
170        unsafe fn commitComposition(&self, sender: Option<&AnyObject>);
171
172        /// Called to get an array of candidates.
173        ///
174        /// 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.
175        ///
176        /// # Safety
177        ///
178        /// - `sender` should be of the correct type.
179        /// - `sender` might not allow `None`.
180        #[unsafe(method(candidates:))]
181        #[unsafe(method_family = none)]
182        unsafe fn candidates(&self, sender: Option<&AnyObject>) -> Option<Retained<NSArray>>;
183    );
184}
185
186impl private_NSObjectIMKServerInput::Sealed for NSObject {}
187unsafe impl NSObjectIMKServerInput for NSObject {}
188
189extern_protocol!(
190    /// This protocol sets or accesses values that indicate the state of an input method.
191    ///
192    /// See also [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkstatesetting?language=objc)
193    pub unsafe trait IMKStateSetting {
194        /// Activates the input method.
195        ///
196        /// # Safety
197        ///
198        /// - `sender` should be of the correct type.
199        /// - `sender` might not allow `None`.
200        #[unsafe(method(activateServer:))]
201        #[unsafe(method_family = none)]
202        unsafe fn activateServer(&self, sender: Option<&AnyObject>);
203
204        /// Deactivate the input method.
205        ///
206        /// # Safety
207        ///
208        /// - `sender` should be of the correct type.
209        /// - `sender` might not allow `None`.
210        #[unsafe(method(deactivateServer:))]
211        #[unsafe(method_family = none)]
212        unsafe fn deactivateServer(&self, sender: Option<&AnyObject>);
213
214        /// Return a object value whose key is tag.  The returned object should be autoreleased.
215        ///
216        /// # Safety
217        ///
218        /// - `sender` should be of the correct type.
219        /// - `sender` might not allow `None`.
220        #[unsafe(method(valueForTag:client:))]
221        #[unsafe(method_family = none)]
222        unsafe fn valueForTag_client(
223            &self,
224            tag: c_long,
225            sender: Option<&AnyObject>,
226        ) -> Option<Retained<AnyObject>>;
227
228        /// Set the tagged value to the object specified by value.
229        ///
230        /// # Safety
231        ///
232        /// - `value` should be of the correct type.
233        /// - `value` might not allow `None`.
234        /// - `sender` should be of the correct type.
235        /// - `sender` might not allow `None`.
236        #[unsafe(method(setValue:forTag:client:))]
237        #[unsafe(method_family = none)]
238        unsafe fn setValue_forTag_client(
239            &self,
240            value: Option<&AnyObject>,
241            tag: c_long,
242            sender: Option<&AnyObject>,
243        );
244
245        /// This is called to obtain the input method's modes dictionary.
246        ///
247        /// Typically this is called to to build the text input menu.  By calling the input method rather than reading the modes from the info.plist the input method can dynamically modify he modes supported. The returned NSDictionary should be an autoreleased object.
248        ///
249        /// # Safety
250        ///
251        /// - `sender` should be of the correct type.
252        /// - `sender` might not allow `None`.
253        #[unsafe(method(modes:))]
254        #[unsafe(method_family = none)]
255        unsafe fn modes(&self, sender: Option<&AnyObject>) -> Option<Retained<NSDictionary>>;
256
257        /// Returns an unsigned integer containing a union of event masks (see NSEvent.h)
258        ///
259        /// A client will check with an input method to see if an event is supported by calling the method.  The default implementation returns NSKeyDownMask.
260        /// If your input method only handles key downs the InputMethodKit provides default mouse handling.  The default mousedown handling behavior is as follows: if there is an active composition area and the user clicks in the text but outside of the composition area the InputMethodKit will send your input method a commitComposition: message. Note that this will only happen for input methods that return just NSKeyDownMask (i.e. the default value) as the result of recognizedEvents.
261        ///
262        /// # Safety
263        ///
264        /// - `sender` should be of the correct type.
265        /// - `sender` might not allow `None`.
266        #[unsafe(method(recognizedEvents:))]
267        #[unsafe(method_family = none)]
268        unsafe fn recognizedEvents(&self, sender: Option<&AnyObject>) -> NSUInteger;
269
270        /// Looks for a nib file containing a windowController class and a preferences utility. If found the panel is displayed.
271        ///
272        /// To use this method include a menu item whose action is showPreferences: in your input method's menu.  If that is done the method will be called automatically when a user selects the item in the Text Input Menu.
273        /// The default implementation looks for a nib file called preferences.nib.  If found a windowController class is allocated and the nib is loaded.  You can provide a custom windowController class by naming the class in your input methods info.plist file.  To do that provide a string value that names the custom class with a key of InputMethodServerPreferencesWindowControllerClass.
274        ///
275        /// # Safety
276        ///
277        /// - `sender` should be of the correct type.
278        /// - `sender` might not allow `None`.
279        #[unsafe(method(showPreferences:))]
280        #[unsafe(method_family = none)]
281        unsafe fn showPreferences(&self, sender: Option<&AnyObject>);
282    }
283);
284
285extern_protocol!(
286    /// This protocol receives mouse events.
287    ///
288    /// See also [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkmousehandling?language=objc)
289    pub unsafe trait IMKMouseHandling {
290        /// Sends a mouseDown to an input method.
291        ///
292        /// A mouse down event happened at given index within the sender�s text storage, at the given point, and with modifier keys identified in flags. Return YES if handled.  Set keepTracking to YES if you want to receive subsequent mouseMoved and mouseUp events.
293        ///
294        /// # Safety
295        ///
296        /// - `keep_tracking` must be a valid pointer.
297        /// - `sender` should be of the correct type.
298        /// - `sender` might not allow `None`.
299        #[unsafe(method(mouseDownOnCharacterIndex:coordinate:withModifier:continueTracking:client:))]
300        #[unsafe(method_family = none)]
301        unsafe fn mouseDownOnCharacterIndex_coordinate_withModifier_continueTracking_client(
302            &self,
303            index: NSUInteger,
304            point: NSPoint,
305            flags: NSUInteger,
306            keep_tracking: *mut Bool,
307            sender: Option<&AnyObject>,
308        ) -> bool;
309
310        /// Sends a mouseUp to an input method.
311        ///
312        /// A mouse up event happened at given index within the sender text view�s text storage, at the given point, with modifier keys identified in flags. Return YES if handled.
313        ///
314        /// # Safety
315        ///
316        /// - `sender` should be of the correct type.
317        /// - `sender` might not allow `None`.
318        #[unsafe(method(mouseUpOnCharacterIndex:coordinate:withModifier:client:))]
319        #[unsafe(method_family = none)]
320        unsafe fn mouseUpOnCharacterIndex_coordinate_withModifier_client(
321            &self,
322            index: NSUInteger,
323            point: NSPoint,
324            flags: NSUInteger,
325            sender: Option<&AnyObject>,
326        ) -> bool;
327
328        /// Passes a mouseMoved event to the input method.
329        ///
330        /// A mouse moved event happened at given index within the sender text view�s text storage, at the given point, with modifier keys identified in flags. Return YES if handled.
331        ///
332        /// # Safety
333        ///
334        /// - `sender` should be of the correct type.
335        /// - `sender` might not allow `None`.
336        #[unsafe(method(mouseMovedOnCharacterIndex:coordinate:withModifier:client:))]
337        #[unsafe(method_family = none)]
338        unsafe fn mouseMovedOnCharacterIndex_coordinate_withModifier_client(
339            &self,
340            index: NSUInteger,
341            point: NSPoint,
342            flags: NSUInteger,
343            sender: Option<&AnyObject>,
344        ) -> bool;
345    }
346);
347
348extern_class!(
349    /// The basic class that controls input on the input method side.
350    ///
351    /// IMKInputController implements fully implements the protocols defined above.  Typically a developer does not override this class, but provides a delegate object that implements the methods that developer is interested in.  The IMKInputController versions of the protocol methods check if the delegate object implements a method, and  call the delegate version if it exists.
352    ///
353    /// The IMKServer class which is allocated in an input method's main function creates a controller class for each input session created by a client application. Therefore for every input session there is a corresponding IMKInputController.
354    ///
355    /// See also [Apple's documentation](https://developer.apple.com/documentation/inputmethodkit/imkinputcontroller?language=objc)
356    #[unsafe(super(NSObject))]
357    #[derive(Debug, PartialEq, Eq, Hash)]
358    pub struct IMKInputController;
359);
360
361extern_conformance!(
362    unsafe impl IMKMouseHandling for IMKInputController {}
363);
364
365extern_conformance!(
366    unsafe impl IMKStateSetting for IMKInputController {}
367);
368
369extern_conformance!(
370    unsafe impl NSObjectProtocol for IMKInputController {}
371);
372
373impl IMKInputController {
374    extern_methods!(
375        #[cfg(feature = "IMKServer")]
376        /// Initializes the controller class setting the delegate.
377        ///
378        /// The inputClient parameter is the client side object that will be sending messages to the controller via the IMKServer.  The client object always conforms to the IMKTextInput protocol.
379        ///
380        /// Methods in the protocols that are implemented by the delegate object always include a client parameter.  Methods in the IMKInputController class do not take a client.  This is because the client is stored as an ivar in the IMKInputController.
381        ///
382        /// # Safety
383        ///
384        /// - `server` might not allow `None`.
385        /// - `delegate` should be of the correct type.
386        /// - `delegate` might not allow `None`.
387        /// - `input_client` should be of the correct type.
388        /// - `input_client` might not allow `None`.
389        #[unsafe(method(initWithServer:delegate:client:))]
390        #[unsafe(method_family = init)]
391        pub unsafe fn initWithServer_delegate_client(
392            this: Allocated<Self>,
393            server: Option<&IMKServer>,
394            delegate: Option<&AnyObject>,
395            input_client: Option<&AnyObject>,
396        ) -> Option<Retained<Self>>;
397
398        /// Called to inform the controller that the composition has changed.
399        ///
400        /// This method will call the protocol method composedString: to obtain the current composition. The current composition will be sent to the client by a call to the method setMarkedText:
401        #[unsafe(method(updateComposition))]
402        #[unsafe(method_family = none)]
403        pub unsafe fn updateComposition(&self);
404
405        /// Stops the current composition and replaces marked text with the original text.
406        ///
407        /// Calls the method originalString to obtain the original text and sends that to the client via a call to IMKInputSession protocol method insertText:
408        #[unsafe(method(cancelComposition))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn cancelComposition(&self);
411
412        /// Called to obtain a dictionary of text attributes.
413        ///
414        /// The default implementation returns an empty dictionary.  You should override this method if your input method wants to provide font or glyphInformation. The returned object should be an autoreleased object.
415        ///
416        /// # Safety
417        ///
418        /// The returned generic should be of the correct type.
419        #[unsafe(method(compositionAttributesAtRange:))]
420        #[unsafe(method_family = none)]
421        pub unsafe fn compositionAttributesAtRange(
422            &self,
423            range: NSRange,
424        ) -> Option<Retained<NSMutableDictionary>>;
425
426        /// Returns where the selection should be placed inside markedText.
427        ///
428        /// This method is called by updateComposition: to obtain the selection range for markedText.  The default implementation sets the selection range at the end of the marked text.
429        #[unsafe(method(selectionRange))]
430        #[unsafe(method_family = none)]
431        pub unsafe fn selectionRange(&self) -> NSRange;
432
433        /// Returns the range in the client document that text should replace.
434        ///
435        /// This method is called by updateComposition to obtain the range in the client's document where markedText should be placed.  The default implementation returns an NSRange whose location and length are NSNotFound.  That indicates that the marked text should be placed at the current insertion point.  Input methods that wish to insert marked text somewhere other than at the current insertion point should override this method.
436        ///
437        /// An example of an input method that might override this method would be one replaced words with synonyms.  That input method would watch for certain words and when one of those words was seen it would be replaced by marked text that was a synonym of the word.
438        #[unsafe(method(replacementRange))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn replacementRange(&self) -> NSRange;
441
442        /// Returns a dictionary of text attributes that can be used to mark a range of an attributed string that is going to be sent to a client.
443        ///
444        /// This utility function can be called by input methods to mark each range (i.e. clause ) of marked text.  The style parameter should be one of the following values: kTSMHiliteSelectedRawText, kTSMHiliteConvertedText or kTSMHiliteSelectedConvertedText. See AERegistry.h for the definition of these values.
445        ///
446        /// The default implementation begins by calling compositionAttributesAtRange: to obtain extra attributes that an input method wants to include such as font or  glyph information.  Then the appropriate underline and underline color information is added to the attributes dictionary for the style parameter.
447        ///
448        /// Finally the style value is added as dictionary value.  The key for the style value is NSMarkedClauseSegment. The returned object should be an autoreleased object.
449        #[unsafe(method(markForStyle:atRange:))]
450        #[unsafe(method_family = none)]
451        pub unsafe fn markForStyle_atRange(
452            &self,
453            style: NSInteger,
454            range: NSRange,
455        ) -> Option<Retained<NSDictionary>>;
456
457        /// Called to pass commands that are not generated as part of the text input.
458        ///
459        /// The default implementation checks if the controller object (i.e. self) responds to the selector.  If that is true the message performSelector:withObject  is sent to the controller class.  The object parameter in that case is the infoDictionary.
460        ///
461        /// This method is called when a user selects a command item from the text input menu.  To support this an input method merely needs to provide actions for each menu item that will be placed in the menu.
462        ///
463        /// i.e. -(void)menuAction:(id)sender
464        ///
465        /// Note that the sender in this instance will be the infoDictionary.  The dictionary contains two values:
466        ///
467        /// kIMKCommandMenuItemName            NSMenuItem  -- the NSMenuItem that was selected
468        /// kIMKCommandClientName            id
469        /// <IMKTextInput
470        /// , NSObject> - the current client
471        ///
472        /// # Safety
473        ///
474        /// - `a_selector` must be a valid selector.
475        /// - `info_dictionary` generic should be of the correct type.
476        /// - `info_dictionary` might not allow `None`.
477        #[unsafe(method(doCommandBySelector:commandDictionary:))]
478        #[unsafe(method_family = none)]
479        pub unsafe fn doCommandBySelector_commandDictionary(
480            &self,
481            a_selector: Option<Sel>,
482            info_dictionary: Option<&NSDictionary>,
483        );
484
485        /// Called to inform an input method that any visible UI should be closed.
486        #[unsafe(method(hidePalettes))]
487        #[unsafe(method_family = none)]
488        pub unsafe fn hidePalettes(&self);
489
490        #[cfg(feature = "objc2-app-kit")]
491        /// Returns a menu of input method specific commands.
492        ///
493        /// This method is called whenever the menu needs to be drawn so that input methods can update the menu to reflect their current state. The returned NSMenu is an autoreleased object.
494        #[unsafe(method(menu))]
495        #[unsafe(method_family = none)]
496        pub unsafe fn menu(&self, mtm: MainThreadMarker) -> Option<Retained<NSMenu>>;
497
498        /// Returns the input controller's delegate object. The returned id is an autoreleased object.
499        #[unsafe(method(delegate))]
500        #[unsafe(method_family = none)]
501        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
502
503        /// Set the input controller's delegate object.
504        ///
505        /// # Safety
506        ///
507        /// - `new_delegate` should be of the correct type.
508        /// - `new_delegate` might not allow `None`.
509        #[unsafe(method(setDelegate:))]
510        #[unsafe(method_family = none)]
511        pub unsafe fn setDelegate(&self, new_delegate: Option<&AnyObject>);
512
513        #[cfg(feature = "IMKServer")]
514        /// Return the server object which is managing this input controller. The returned IMKServer is an autoreleased object.
515        #[unsafe(method(server))]
516        #[unsafe(method_family = none)]
517        pub unsafe fn server(&self) -> Option<Retained<IMKServer>>;
518
519        /// Called to notify an input controller that it is about to be closed.
520        #[unsafe(method(inputControllerWillClose))]
521        #[unsafe(method_family = none)]
522        pub unsafe fn inputControllerWillClose(&self);
523
524        /// Called when a user has selected a annotation in a candidate window.
525        ///
526        /// When a candidate window is displayed and the user selects an annotation the selected annotation is sent to the input controller via this method.  The currently selected candidateString is also sent to the input method.
527        ///
528        /// # Safety
529        ///
530        /// - `annotation_string` might not allow `None`.
531        /// - `candidate_string` might not allow `None`.
532        #[unsafe(method(annotationSelected:forCandidate:))]
533        #[unsafe(method_family = none)]
534        pub unsafe fn annotationSelected_forCandidate(
535            &self,
536            annotation_string: Option<&NSAttributedString>,
537            candidate_string: Option<&NSAttributedString>,
538        );
539
540        /// Informs an input controller that the current candidate selection in the candidate window has changed.
541        ///
542        /// The candidate parameter is the candidate string that the selection changed to.  Note this method is called to indicate that the user is moving around in the candidate window.  The candidate object is not a final selection.
543        ///
544        /// # Safety
545        ///
546        /// `candidate_string` might not allow `None`.
547        #[unsafe(method(candidateSelectionChanged:))]
548        #[unsafe(method_family = none)]
549        pub unsafe fn candidateSelectionChanged(
550            &self,
551            candidate_string: Option<&NSAttributedString>,
552        );
553
554        /// Called when a new candidate has been finally selected.
555        ///
556        /// The candidate parameter is the users final choice from the candidate window. The candidate window will have been closed before this method is called.
557        ///
558        /// # Safety
559        ///
560        /// `candidate_string` might not allow `None`.
561        #[unsafe(method(candidateSelected:))]
562        #[unsafe(method_family = none)]
563        pub unsafe fn candidateSelected(&self, candidate_string: Option<&NSAttributedString>);
564    );
565}
566
567/// Methods declared on superclass `NSObject`.
568impl IMKInputController {
569    extern_methods!(
570        #[unsafe(method(init))]
571        #[unsafe(method_family = init)]
572        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
573
574        #[unsafe(method(new))]
575        #[unsafe(method_family = new)]
576        pub unsafe fn new() -> Retained<Self>;
577    );
578}