objc2_ui_kit/generated/
UITextInput.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-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_protocol!(
13    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinput?language=objc)
14    #[cfg(feature = "UITextInputTraits")]
15    pub unsafe trait UIKeyInput: UITextInputTraits + MainThreadOnly {
16        #[unsafe(method(hasText))]
17        #[unsafe(method_family = none)]
18        fn hasText(&self) -> bool;
19
20        #[unsafe(method(insertText:))]
21        #[unsafe(method_family = none)]
22        fn insertText(&self, text: &NSString);
23
24        #[unsafe(method(deleteBackward))]
25        #[unsafe(method_family = none)]
26        fn deleteBackward(&self);
27    }
28);
29
30/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextstoragedirection?language=objc)
31// NS_ENUM
32#[repr(transparent)]
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
34pub struct UITextStorageDirection(pub NSInteger);
35impl UITextStorageDirection {
36    #[doc(alias = "UITextStorageDirectionForward")]
37    pub const Forward: Self = Self(0);
38    #[doc(alias = "UITextStorageDirectionBackward")]
39    pub const Backward: Self = Self(1);
40}
41
42unsafe impl Encode for UITextStorageDirection {
43    const ENCODING: Encoding = NSInteger::ENCODING;
44}
45
46unsafe impl RefEncode for UITextStorageDirection {
47    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
48}
49
50/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextlayoutdirection?language=objc)
51// NS_ENUM
52#[repr(transparent)]
53#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
54pub struct UITextLayoutDirection(pub NSInteger);
55impl UITextLayoutDirection {
56    #[doc(alias = "UITextLayoutDirectionRight")]
57    pub const Right: Self = Self(2);
58    #[doc(alias = "UITextLayoutDirectionLeft")]
59    pub const Left: Self = Self(3);
60    #[doc(alias = "UITextLayoutDirectionUp")]
61    pub const Up: Self = Self(4);
62    #[doc(alias = "UITextLayoutDirectionDown")]
63    pub const Down: Self = Self(5);
64}
65
66unsafe impl Encode for UITextLayoutDirection {
67    const ENCODING: Encoding = NSInteger::ENCODING;
68}
69
70unsafe impl RefEncode for UITextLayoutDirection {
71    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextdirection?language=objc)
75// NS_TYPED_ENUM
76pub type UITextDirection = NSInteger;
77
78/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextgranularity?language=objc)
79// NS_ENUM
80#[repr(transparent)]
81#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
82pub struct UITextGranularity(pub NSInteger);
83impl UITextGranularity {
84    #[doc(alias = "UITextGranularityCharacter")]
85    pub const Character: Self = Self(0);
86    #[doc(alias = "UITextGranularityWord")]
87    pub const Word: Self = Self(1);
88    #[doc(alias = "UITextGranularitySentence")]
89    pub const Sentence: Self = Self(2);
90    #[doc(alias = "UITextGranularityParagraph")]
91    pub const Paragraph: Self = Self(3);
92    #[doc(alias = "UITextGranularityLine")]
93    pub const Line: Self = Self(4);
94    #[doc(alias = "UITextGranularityDocument")]
95    pub const Document: Self = Self(5);
96}
97
98unsafe impl Encode for UITextGranularity {
99    const ENCODING: Encoding = NSInteger::ENCODING;
100}
101
102unsafe impl RefEncode for UITextGranularity {
103    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
104}
105
106extern_class!(
107    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidictationphrase?language=objc)
108    #[unsafe(super(NSObject))]
109    #[thread_kind = MainThreadOnly]
110    #[derive(Debug, PartialEq, Eq, Hash)]
111    pub struct UIDictationPhrase;
112);
113
114extern_conformance!(
115    unsafe impl NSObjectProtocol for UIDictationPhrase {}
116);
117
118impl UIDictationPhrase {
119    extern_methods!(
120        #[unsafe(method(text))]
121        #[unsafe(method_family = none)]
122        pub fn text(&self) -> Retained<NSString>;
123
124        #[unsafe(method(alternativeInterpretations))]
125        #[unsafe(method_family = none)]
126        pub fn alternativeInterpretations(&self) -> Option<Retained<NSArray<NSString>>>;
127    );
128}
129
130/// Methods declared on superclass `NSObject`.
131impl UIDictationPhrase {
132    extern_methods!(
133        #[unsafe(method(init))]
134        #[unsafe(method_family = init)]
135        pub fn init(this: Allocated<Self>) -> Retained<Self>;
136
137        #[unsafe(method(new))]
138        #[unsafe(method_family = new)]
139        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
140    );
141}
142
143extern_class!(
144    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputassistantitem?language=objc)
145    #[unsafe(super(NSObject))]
146    #[thread_kind = MainThreadOnly]
147    #[derive(Debug, PartialEq, Eq, Hash)]
148    pub struct UITextInputAssistantItem;
149);
150
151extern_conformance!(
152    unsafe impl NSObjectProtocol for UITextInputAssistantItem {}
153);
154
155impl UITextInputAssistantItem {
156    extern_methods!(
157        /// Default is YES, controls if the user is allowed to hide the shortcuts bar. Does not influence the built in auto-hiding logic.
158        #[unsafe(method(allowsHidingShortcuts))]
159        #[unsafe(method_family = none)]
160        pub fn allowsHidingShortcuts(&self) -> bool;
161
162        /// Setter for [`allowsHidingShortcuts`][Self::allowsHidingShortcuts].
163        #[unsafe(method(setAllowsHidingShortcuts:))]
164        #[unsafe(method_family = none)]
165        pub fn setAllowsHidingShortcuts(&self, allows_hiding_shortcuts: bool);
166
167        #[cfg(feature = "UIBarButtonItemGroup")]
168        /// Contains UIBarButtonItemGroups that should be displayed in the leading position on the keyboard's assistant bar.
169        #[unsafe(method(leadingBarButtonGroups))]
170        #[unsafe(method_family = none)]
171        pub fn leadingBarButtonGroups(&self) -> Retained<NSArray<UIBarButtonItemGroup>>;
172
173        #[cfg(feature = "UIBarButtonItemGroup")]
174        /// Setter for [`leadingBarButtonGroups`][Self::leadingBarButtonGroups].
175        ///
176        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
177        #[unsafe(method(setLeadingBarButtonGroups:))]
178        #[unsafe(method_family = none)]
179        pub fn setLeadingBarButtonGroups(
180            &self,
181            leading_bar_button_groups: &NSArray<UIBarButtonItemGroup>,
182        );
183
184        #[cfg(feature = "UIBarButtonItemGroup")]
185        /// Contains UIBarButtonItemGroups that should be displayed in the trailing position on the keyboard's assistant bar.
186        #[unsafe(method(trailingBarButtonGroups))]
187        #[unsafe(method_family = none)]
188        pub fn trailingBarButtonGroups(&self) -> Retained<NSArray<UIBarButtonItemGroup>>;
189
190        #[cfg(feature = "UIBarButtonItemGroup")]
191        /// Setter for [`trailingBarButtonGroups`][Self::trailingBarButtonGroups].
192        ///
193        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
194        #[unsafe(method(setTrailingBarButtonGroups:))]
195        #[unsafe(method_family = none)]
196        pub fn setTrailingBarButtonGroups(
197            &self,
198            trailing_bar_button_groups: &NSArray<UIBarButtonItemGroup>,
199        );
200
201        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
202        /// A button that appears next to the text preview in the keyboard on visionOS.
203        #[unsafe(method(keyboardActionButtonItem))]
204        #[unsafe(method_family = none)]
205        pub fn keyboardActionButtonItem(&self) -> Option<Retained<UIBarButtonItem>>;
206
207        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
208        /// Setter for [`keyboardActionButtonItem`][Self::keyboardActionButtonItem].
209        #[unsafe(method(setKeyboardActionButtonItem:))]
210        #[unsafe(method_family = none)]
211        pub fn setKeyboardActionButtonItem(
212            &self,
213            keyboard_action_button_item: Option<&UIBarButtonItem>,
214        );
215    );
216}
217
218/// Methods declared on superclass `NSObject`.
219impl UITextInputAssistantItem {
220    extern_methods!(
221        #[unsafe(method(init))]
222        #[unsafe(method_family = init)]
223        pub fn init(this: Allocated<Self>) -> Retained<Self>;
224
225        #[unsafe(method(new))]
226        #[unsafe(method_family = new)]
227        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
228    );
229}
230
231extern_class!(
232    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextplaceholder?language=objc)
233    #[unsafe(super(NSObject))]
234    #[thread_kind = MainThreadOnly]
235    #[derive(Debug, PartialEq, Eq, Hash)]
236    pub struct UITextPlaceholder;
237);
238
239extern_conformance!(
240    unsafe impl NSObjectProtocol for UITextPlaceholder {}
241);
242
243impl UITextPlaceholder {
244    extern_methods!(
245        #[unsafe(method(rects))]
246        #[unsafe(method_family = none)]
247        pub fn rects(&self) -> Retained<NSArray<UITextSelectionRect>>;
248    );
249}
250
251/// Methods declared on superclass `NSObject`.
252impl UITextPlaceholder {
253    extern_methods!(
254        #[unsafe(method(init))]
255        #[unsafe(method_family = init)]
256        pub fn init(this: Allocated<Self>) -> Retained<Self>;
257
258        #[unsafe(method(new))]
259        #[unsafe(method_family = new)]
260        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
261    );
262}
263
264/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextalternativestyle?language=objc)
265// NS_ENUM
266#[repr(transparent)]
267#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
268pub struct UITextAlternativeStyle(pub NSInteger);
269impl UITextAlternativeStyle {
270    #[doc(alias = "UITextAlternativeStyleNone")]
271    pub const None: Self = Self(0);
272    #[doc(alias = "UITextAlternativeStyleLowConfidence")]
273    pub const LowConfidence: Self = Self(1);
274}
275
276unsafe impl Encode for UITextAlternativeStyle {
277    const ENCODING: Encoding = NSInteger::ENCODING;
278}
279
280unsafe impl RefEncode for UITextAlternativeStyle {
281    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
282}
283
284extern_protocol!(
285    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinput?language=objc)
286    #[cfg(feature = "UITextInputTraits")]
287    pub unsafe trait UITextInput: UIKeyInput + MainThreadOnly {
288        #[unsafe(method(textInRange:))]
289        #[unsafe(method_family = none)]
290        fn textInRange(&self, range: &UITextRange) -> Option<Retained<NSString>>;
291
292        #[unsafe(method(replaceRange:withText:))]
293        #[unsafe(method_family = none)]
294        fn replaceRange_withText(&self, range: &UITextRange, text: &NSString);
295
296        #[unsafe(method(selectedTextRange))]
297        #[unsafe(method_family = none)]
298        fn selectedTextRange(&self) -> Option<Retained<UITextRange>>;
299
300        /// Setter for [`selectedTextRange`][Self::selectedTextRange].
301        ///
302        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
303        #[unsafe(method(setSelectedTextRange:))]
304        #[unsafe(method_family = none)]
305        fn setSelectedTextRange(&self, selected_text_range: Option<&UITextRange>);
306
307        #[unsafe(method(markedTextRange))]
308        #[unsafe(method_family = none)]
309        fn markedTextRange(&self) -> Option<Retained<UITextRange>>;
310
311        #[unsafe(method(markedTextStyle))]
312        #[unsafe(method_family = none)]
313        fn markedTextStyle(
314            &self,
315        ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
316
317        /// Setter for [`markedTextStyle`][Self::markedTextStyle].
318        ///
319        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
320        ///
321        /// # Safety
322        ///
323        /// `marked_text_style` generic should be of the correct type.
324        #[unsafe(method(setMarkedTextStyle:))]
325        #[unsafe(method_family = none)]
326        unsafe fn setMarkedTextStyle(
327            &self,
328            marked_text_style: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
329        );
330
331        #[unsafe(method(setMarkedText:selectedRange:))]
332        #[unsafe(method_family = none)]
333        fn setMarkedText_selectedRange(
334            &self,
335            marked_text: Option<&NSString>,
336            selected_range: NSRange,
337        );
338
339        #[unsafe(method(unmarkText))]
340        #[unsafe(method_family = none)]
341        fn unmarkText(&self);
342
343        #[unsafe(method(beginningOfDocument))]
344        #[unsafe(method_family = none)]
345        fn beginningOfDocument(&self) -> Retained<UITextPosition>;
346
347        #[unsafe(method(endOfDocument))]
348        #[unsafe(method_family = none)]
349        fn endOfDocument(&self) -> Retained<UITextPosition>;
350
351        #[unsafe(method(textRangeFromPosition:toPosition:))]
352        #[unsafe(method_family = none)]
353        fn textRangeFromPosition_toPosition(
354            &self,
355            from_position: &UITextPosition,
356            to_position: &UITextPosition,
357        ) -> Option<Retained<UITextRange>>;
358
359        #[unsafe(method(positionFromPosition:offset:))]
360        #[unsafe(method_family = none)]
361        fn positionFromPosition_offset(
362            &self,
363            position: &UITextPosition,
364            offset: NSInteger,
365        ) -> Option<Retained<UITextPosition>>;
366
367        #[unsafe(method(positionFromPosition:inDirection:offset:))]
368        #[unsafe(method_family = none)]
369        fn positionFromPosition_inDirection_offset(
370            &self,
371            position: &UITextPosition,
372            direction: UITextLayoutDirection,
373            offset: NSInteger,
374        ) -> Option<Retained<UITextPosition>>;
375
376        #[unsafe(method(comparePosition:toPosition:))]
377        #[unsafe(method_family = none)]
378        fn comparePosition_toPosition(
379            &self,
380            position: &UITextPosition,
381            other: &UITextPosition,
382        ) -> NSComparisonResult;
383
384        #[unsafe(method(offsetFromPosition:toPosition:))]
385        #[unsafe(method_family = none)]
386        fn offsetFromPosition_toPosition(
387            &self,
388            from: &UITextPosition,
389            to_position: &UITextPosition,
390        ) -> NSInteger;
391
392        #[unsafe(method(inputDelegate))]
393        #[unsafe(method_family = none)]
394        fn inputDelegate(&self) -> Option<Retained<ProtocolObject<dyn UITextInputDelegate>>>;
395
396        /// Setter for [`inputDelegate`][Self::inputDelegate].
397        ///
398        /// This is a [weak property][objc2::topics::weak_property].
399        #[unsafe(method(setInputDelegate:))]
400        #[unsafe(method_family = none)]
401        fn setInputDelegate(
402            &self,
403            input_delegate: Option<&ProtocolObject<dyn UITextInputDelegate>>,
404        );
405
406        #[unsafe(method(tokenizer))]
407        #[unsafe(method_family = none)]
408        fn tokenizer(&self) -> Retained<ProtocolObject<dyn UITextInputTokenizer>>;
409
410        #[unsafe(method(positionWithinRange:farthestInDirection:))]
411        #[unsafe(method_family = none)]
412        fn positionWithinRange_farthestInDirection(
413            &self,
414            range: &UITextRange,
415            direction: UITextLayoutDirection,
416        ) -> Option<Retained<UITextPosition>>;
417
418        #[unsafe(method(characterRangeByExtendingPosition:inDirection:))]
419        #[unsafe(method_family = none)]
420        fn characterRangeByExtendingPosition_inDirection(
421            &self,
422            position: &UITextPosition,
423            direction: UITextLayoutDirection,
424        ) -> Option<Retained<UITextRange>>;
425
426        #[cfg(feature = "NSText")]
427        #[unsafe(method(baseWritingDirectionForPosition:inDirection:))]
428        #[unsafe(method_family = none)]
429        fn baseWritingDirectionForPosition_inDirection(
430            &self,
431            position: &UITextPosition,
432            direction: UITextStorageDirection,
433        ) -> NSWritingDirection;
434
435        #[cfg(feature = "NSText")]
436        #[unsafe(method(setBaseWritingDirection:forRange:))]
437        #[unsafe(method_family = none)]
438        fn setBaseWritingDirection_forRange(
439            &self,
440            writing_direction: NSWritingDirection,
441            range: &UITextRange,
442        );
443
444        #[cfg(feature = "objc2-core-foundation")]
445        #[unsafe(method(firstRectForRange:))]
446        #[unsafe(method_family = none)]
447        fn firstRectForRange(&self, range: &UITextRange) -> CGRect;
448
449        #[cfg(feature = "objc2-core-foundation")]
450        #[unsafe(method(caretRectForPosition:))]
451        #[unsafe(method_family = none)]
452        fn caretRectForPosition(&self, position: &UITextPosition) -> CGRect;
453
454        #[unsafe(method(selectionRectsForRange:))]
455        #[unsafe(method_family = none)]
456        fn selectionRectsForRange(
457            &self,
458            range: &UITextRange,
459        ) -> Retained<NSArray<UITextSelectionRect>>;
460
461        #[cfg(feature = "objc2-core-foundation")]
462        #[unsafe(method(closestPositionToPoint:))]
463        #[unsafe(method_family = none)]
464        fn closestPositionToPoint(&self, point: CGPoint) -> Option<Retained<UITextPosition>>;
465
466        #[cfg(feature = "objc2-core-foundation")]
467        #[unsafe(method(closestPositionToPoint:withinRange:))]
468        #[unsafe(method_family = none)]
469        fn closestPositionToPoint_withinRange(
470            &self,
471            point: CGPoint,
472            range: &UITextRange,
473        ) -> Option<Retained<UITextPosition>>;
474
475        #[cfg(feature = "objc2-core-foundation")]
476        #[unsafe(method(characterRangeAtPoint:))]
477        #[unsafe(method_family = none)]
478        fn characterRangeAtPoint(&self, point: CGPoint) -> Option<Retained<UITextRange>>;
479
480        #[optional]
481        #[unsafe(method(shouldChangeTextInRange:replacementText:))]
482        #[unsafe(method_family = none)]
483        fn shouldChangeTextInRange_replacementText(
484            &self,
485            range: &UITextRange,
486            text: &NSString,
487        ) -> bool;
488
489        #[optional]
490        #[unsafe(method(textStylingAtPosition:inDirection:))]
491        #[unsafe(method_family = none)]
492        fn textStylingAtPosition_inDirection(
493            &self,
494            position: &UITextPosition,
495            direction: UITextStorageDirection,
496        ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
497
498        #[optional]
499        #[unsafe(method(positionWithinRange:atCharacterOffset:))]
500        #[unsafe(method_family = none)]
501        fn positionWithinRange_atCharacterOffset(
502            &self,
503            range: &UITextRange,
504            offset: NSInteger,
505        ) -> Option<Retained<UITextPosition>>;
506
507        #[optional]
508        #[unsafe(method(characterOffsetOfPosition:withinRange:))]
509        #[unsafe(method_family = none)]
510        fn characterOffsetOfPosition_withinRange(
511            &self,
512            position: &UITextPosition,
513            range: &UITextRange,
514        ) -> NSInteger;
515
516        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
517        #[optional]
518        #[unsafe(method(textInputView))]
519        #[unsafe(method_family = none)]
520        fn textInputView(&self) -> Retained<UIView>;
521
522        #[optional]
523        #[unsafe(method(selectionAffinity))]
524        #[unsafe(method_family = none)]
525        fn selectionAffinity(&self) -> UITextStorageDirection;
526
527        /// Setter for [`selectionAffinity`][Self::selectionAffinity].
528        #[optional]
529        #[unsafe(method(setSelectionAffinity:))]
530        #[unsafe(method_family = none)]
531        fn setSelectionAffinity(&self, selection_affinity: UITextStorageDirection);
532
533        #[optional]
534        #[unsafe(method(insertDictationResult:))]
535        #[unsafe(method_family = none)]
536        fn insertDictationResult(&self, dictation_result: &NSArray<UIDictationPhrase>);
537
538        #[optional]
539        #[unsafe(method(dictationRecordingDidEnd))]
540        #[unsafe(method_family = none)]
541        fn dictationRecordingDidEnd(&self);
542
543        #[optional]
544        #[unsafe(method(dictationRecognitionFailed))]
545        #[unsafe(method_family = none)]
546        fn dictationRecognitionFailed(&self);
547
548        #[optional]
549        #[unsafe(method(insertDictationResultPlaceholder))]
550        #[unsafe(method_family = none)]
551        fn insertDictationResultPlaceholder(&self) -> Retained<AnyObject>;
552
553        #[cfg(feature = "objc2-core-foundation")]
554        /// # Safety
555        ///
556        /// `placeholder` should be of the correct type.
557        #[optional]
558        #[unsafe(method(frameForDictationResultPlaceholder:))]
559        #[unsafe(method_family = none)]
560        unsafe fn frameForDictationResultPlaceholder(&self, placeholder: &AnyObject) -> CGRect;
561
562        /// # Safety
563        ///
564        /// `placeholder` should be of the correct type.
565        #[optional]
566        #[unsafe(method(removeDictationResultPlaceholder:willInsertResult:))]
567        #[unsafe(method_family = none)]
568        unsafe fn removeDictationResultPlaceholder_willInsertResult(
569            &self,
570            placeholder: &AnyObject,
571            will_insert_result: bool,
572        );
573
574        #[optional]
575        #[unsafe(method(insertText:alternatives:style:))]
576        #[unsafe(method_family = none)]
577        fn insertText_alternatives_style(
578            &self,
579            text: &NSString,
580            alternatives: &NSArray<NSString>,
581            style: UITextAlternativeStyle,
582        );
583
584        #[optional]
585        #[unsafe(method(setAttributedMarkedText:selectedRange:))]
586        #[unsafe(method_family = none)]
587        fn setAttributedMarkedText_selectedRange(
588            &self,
589            marked_text: Option<&NSAttributedString>,
590            selected_range: NSRange,
591        );
592
593        #[cfg(feature = "objc2-core-foundation")]
594        #[optional]
595        #[unsafe(method(insertTextPlaceholderWithSize:))]
596        #[unsafe(method_family = none)]
597        fn insertTextPlaceholderWithSize(&self, size: CGSize) -> Retained<UITextPlaceholder>;
598
599        #[optional]
600        #[unsafe(method(removeTextPlaceholder:))]
601        #[unsafe(method_family = none)]
602        fn removeTextPlaceholder(&self, text_placeholder: &UITextPlaceholder);
603
604        #[cfg(feature = "objc2-core-foundation")]
605        #[optional]
606        #[unsafe(method(beginFloatingCursorAtPoint:))]
607        #[unsafe(method_family = none)]
608        fn beginFloatingCursorAtPoint(&self, point: CGPoint);
609
610        #[cfg(feature = "objc2-core-foundation")]
611        #[optional]
612        #[unsafe(method(updateFloatingCursorAtPoint:))]
613        #[unsafe(method_family = none)]
614        fn updateFloatingCursorAtPoint(&self, point: CGPoint);
615
616        #[optional]
617        #[unsafe(method(endFloatingCursor))]
618        #[unsafe(method_family = none)]
619        fn endFloatingCursor(&self);
620
621        #[cfg(feature = "objc2-core-foundation")]
622        /// Similar to `-caretRectForPosition:`, optionally provide a transform for the caret at `position`. As with all geometry information in this protocol,
623        /// transforms are assumed to be relative to the `textInputView` coordinate space. If unimplemented, the identity transform is assumed.
624        #[optional]
625        #[unsafe(method(caretTransformForPosition:))]
626        #[unsafe(method_family = none)]
627        fn caretTransformForPosition(&self, position: &UITextPosition) -> CGAffineTransform;
628
629        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
630        /// Called when the text input is preparing an edit menu presentation for the specified text range.
631        ///
632        ///
633        /// Parameter `textRange`: The text range for which the menu is presented for.
634        ///
635        /// Parameter `suggestedActions`: The actions and commands that the system suggests.
636        ///
637        ///
638        /// Returns: Return a UIMenu describing the desired menu hierarchy. Return
639        /// `nil`to present the default system menu.
640        #[optional]
641        #[unsafe(method(editMenuForTextRange:suggestedActions:))]
642        #[unsafe(method_family = none)]
643        fn editMenuForTextRange_suggestedActions(
644            &self,
645            text_range: &UITextRange,
646            suggested_actions: &NSArray<UIMenuElement>,
647        ) -> Option<Retained<UIMenu>>;
648
649        #[cfg(feature = "UIEditMenuInteraction")]
650        #[optional]
651        #[unsafe(method(willPresentEditMenuWithAnimator:))]
652        #[unsafe(method_family = none)]
653        fn willPresentEditMenuWithAnimator(
654            &self,
655            animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
656        );
657
658        #[cfg(feature = "UIEditMenuInteraction")]
659        #[optional]
660        #[unsafe(method(willDismissEditMenuWithAnimator:))]
661        #[unsafe(method_family = none)]
662        fn willDismissEditMenuWithAnimator(
663            &self,
664            animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
665        );
666
667        #[optional]
668        #[unsafe(method(supportsAdaptiveImageGlyph))]
669        #[unsafe(method_family = none)]
670        fn supportsAdaptiveImageGlyph(&self) -> bool;
671
672        /// Setter for [`supportsAdaptiveImageGlyph`][Self::supportsAdaptiveImageGlyph].
673        #[optional]
674        #[unsafe(method(setSupportsAdaptiveImageGlyph:))]
675        #[unsafe(method_family = none)]
676        fn setSupportsAdaptiveImageGlyph(&self, supports_adaptive_image_glyph: bool);
677
678        #[cfg(feature = "NSAdaptiveImageGlyph")]
679        #[optional]
680        #[unsafe(method(insertAdaptiveImageGlyph:replacementRange:))]
681        #[unsafe(method_family = none)]
682        fn insertAdaptiveImageGlyph_replacementRange(
683            &self,
684            adaptive_image_glyph: &NSAdaptiveImageGlyph,
685            replacement_range: &UITextRange,
686        );
687
688        #[optional]
689        #[unsafe(method(isEditable))]
690        #[unsafe(method_family = none)]
691        fn isEditable(&self) -> bool;
692
693        #[optional]
694        #[unsafe(method(insertAttributedText:))]
695        #[unsafe(method_family = none)]
696        fn insertAttributedText(&self, string: &NSAttributedString);
697
698        #[optional]
699        #[unsafe(method(attributedTextInRange:))]
700        #[unsafe(method_family = none)]
701        fn attributedTextInRange(&self, range: &UITextRange) -> Retained<NSAttributedString>;
702
703        #[optional]
704        #[unsafe(method(replaceRange:withAttributedText:))]
705        #[unsafe(method_family = none)]
706        fn replaceRange_withAttributedText(
707            &self,
708            range: &UITextRange,
709            attributed_text: &NSAttributedString,
710        );
711
712        #[optional]
713        #[unsafe(method(willPresentWritingTools))]
714        #[unsafe(method_family = none)]
715        fn willPresentWritingTools(&self);
716
717        #[optional]
718        #[unsafe(method(didDismissWritingTools))]
719        #[unsafe(method_family = none)]
720        fn didDismissWritingTools(&self);
721
722        #[cfg(feature = "UIInputSuggestion")]
723        /// Inserts the user or system’s input suggestion into the document.
724        #[optional]
725        #[unsafe(method(insertInputSuggestion:))]
726        #[unsafe(method_family = none)]
727        fn insertInputSuggestion(&self, input_suggestion: &UIInputSuggestion);
728    }
729);
730
731extern "C" {
732    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputtextbackgroundcolorkey?language=objc)
733    #[deprecated]
734    pub static UITextInputTextBackgroundColorKey: &'static NSString;
735}
736
737extern "C" {
738    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputtextcolorkey?language=objc)
739    #[deprecated]
740    pub static UITextInputTextColorKey: &'static NSString;
741}
742
743extern "C" {
744    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputtextfontkey?language=objc)
745    #[deprecated]
746    pub static UITextInputTextFontKey: &'static NSString;
747}
748
749extern_class!(
750    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextposition?language=objc)
751    #[unsafe(super(NSObject))]
752    #[thread_kind = MainThreadOnly]
753    #[derive(Debug, PartialEq, Eq, Hash)]
754    pub struct UITextPosition;
755);
756
757extern_conformance!(
758    unsafe impl NSObjectProtocol for UITextPosition {}
759);
760
761impl UITextPosition {
762    extern_methods!();
763}
764
765/// Methods declared on superclass `NSObject`.
766impl UITextPosition {
767    extern_methods!(
768        #[unsafe(method(init))]
769        #[unsafe(method_family = init)]
770        pub fn init(this: Allocated<Self>) -> Retained<Self>;
771
772        #[unsafe(method(new))]
773        #[unsafe(method_family = new)]
774        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
775    );
776}
777
778extern_class!(
779    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextrange?language=objc)
780    #[unsafe(super(NSObject))]
781    #[thread_kind = MainThreadOnly]
782    #[derive(Debug, PartialEq, Eq, Hash)]
783    pub struct UITextRange;
784);
785
786extern_conformance!(
787    unsafe impl NSObjectProtocol for UITextRange {}
788);
789
790impl UITextRange {
791    extern_methods!(
792        #[unsafe(method(isEmpty))]
793        #[unsafe(method_family = none)]
794        pub fn isEmpty(&self) -> bool;
795
796        #[unsafe(method(start))]
797        #[unsafe(method_family = none)]
798        pub fn start(&self) -> Retained<UITextPosition>;
799
800        #[unsafe(method(end))]
801        #[unsafe(method_family = none)]
802        pub fn end(&self) -> Retained<UITextPosition>;
803    );
804}
805
806/// Methods declared on superclass `NSObject`.
807impl UITextRange {
808    extern_methods!(
809        #[unsafe(method(init))]
810        #[unsafe(method_family = init)]
811        pub fn init(this: Allocated<Self>) -> Retained<Self>;
812
813        #[unsafe(method(new))]
814        #[unsafe(method_family = new)]
815        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
816    );
817}
818
819extern_class!(
820    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextselectionrect?language=objc)
821    #[unsafe(super(NSObject))]
822    #[thread_kind = MainThreadOnly]
823    #[derive(Debug, PartialEq, Eq, Hash)]
824    pub struct UITextSelectionRect;
825);
826
827extern_conformance!(
828    unsafe impl NSObjectProtocol for UITextSelectionRect {}
829);
830
831impl UITextSelectionRect {
832    extern_methods!(
833        #[cfg(feature = "objc2-core-foundation")]
834        #[unsafe(method(rect))]
835        #[unsafe(method_family = none)]
836        pub fn rect(&self) -> CGRect;
837
838        #[cfg(feature = "NSText")]
839        #[unsafe(method(writingDirection))]
840        #[unsafe(method_family = none)]
841        pub fn writingDirection(&self) -> NSWritingDirection;
842
843        #[unsafe(method(containsStart))]
844        #[unsafe(method_family = none)]
845        pub fn containsStart(&self) -> bool;
846
847        #[unsafe(method(containsEnd))]
848        #[unsafe(method_family = none)]
849        pub fn containsEnd(&self) -> bool;
850
851        #[unsafe(method(isVertical))]
852        #[unsafe(method_family = none)]
853        pub fn isVertical(&self) -> bool;
854
855        #[cfg(feature = "objc2-core-foundation")]
856        /// Custom transform for highlight rects.
857        /// This transform is assumed to be in the `textInputView` coordinate space.
858        /// Default is CGAffineTransformIdentity (no transform applied).
859        #[unsafe(method(transform))]
860        #[unsafe(method_family = none)]
861        pub fn transform(&self) -> CGAffineTransform;
862    );
863}
864
865/// Methods declared on superclass `NSObject`.
866impl UITextSelectionRect {
867    extern_methods!(
868        #[unsafe(method(init))]
869        #[unsafe(method_family = init)]
870        pub fn init(this: Allocated<Self>) -> Retained<Self>;
871
872        #[unsafe(method(new))]
873        #[unsafe(method_family = new)]
874        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
875    );
876}
877
878extern_protocol!(
879    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputdelegate?language=objc)
880    pub unsafe trait UITextInputDelegate: NSObjectProtocol + MainThreadOnly {
881        #[cfg(feature = "UITextInputTraits")]
882        #[unsafe(method(selectionWillChange:))]
883        #[unsafe(method_family = none)]
884        fn selectionWillChange(&self, text_input: Option<&ProtocolObject<dyn UITextInput>>);
885
886        #[cfg(feature = "UITextInputTraits")]
887        #[unsafe(method(selectionDidChange:))]
888        #[unsafe(method_family = none)]
889        fn selectionDidChange(&self, text_input: Option<&ProtocolObject<dyn UITextInput>>);
890
891        #[cfg(feature = "UITextInputTraits")]
892        #[unsafe(method(textWillChange:))]
893        #[unsafe(method_family = none)]
894        fn textWillChange(&self, text_input: Option<&ProtocolObject<dyn UITextInput>>);
895
896        #[cfg(feature = "UITextInputTraits")]
897        #[unsafe(method(textDidChange:))]
898        #[unsafe(method_family = none)]
899        fn textDidChange(&self, text_input: Option<&ProtocolObject<dyn UITextInput>>);
900
901        #[cfg(all(feature = "UIConversationContext", feature = "UITextInputTraits"))]
902        /// Tells the input delegate when text has changed in the input object for a conversation.
903        #[unsafe(method(conversationContext:didChange:))]
904        #[unsafe(method_family = none)]
905        fn conversationContext_didChange(
906            &self,
907            context: Option<&UIConversationContext>,
908            text_input: Option<&ProtocolObject<dyn UITextInput>>,
909        );
910    }
911);
912
913extern_protocol!(
914    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputtokenizer?language=objc)
915    pub unsafe trait UITextInputTokenizer: NSObjectProtocol + MainThreadOnly {
916        #[unsafe(method(rangeEnclosingPosition:withGranularity:inDirection:))]
917        #[unsafe(method_family = none)]
918        fn rangeEnclosingPosition_withGranularity_inDirection(
919            &self,
920            position: &UITextPosition,
921            granularity: UITextGranularity,
922            direction: UITextDirection,
923        ) -> Option<Retained<UITextRange>>;
924
925        #[unsafe(method(isPosition:atBoundary:inDirection:))]
926        #[unsafe(method_family = none)]
927        fn isPosition_atBoundary_inDirection(
928            &self,
929            position: &UITextPosition,
930            granularity: UITextGranularity,
931            direction: UITextDirection,
932        ) -> bool;
933
934        #[unsafe(method(positionFromPosition:toBoundary:inDirection:))]
935        #[unsafe(method_family = none)]
936        fn positionFromPosition_toBoundary_inDirection(
937            &self,
938            position: &UITextPosition,
939            granularity: UITextGranularity,
940            direction: UITextDirection,
941        ) -> Option<Retained<UITextPosition>>;
942
943        #[unsafe(method(isPosition:withinTextUnit:inDirection:))]
944        #[unsafe(method_family = none)]
945        fn isPosition_withinTextUnit_inDirection(
946            &self,
947            position: &UITextPosition,
948            granularity: UITextGranularity,
949            direction: UITextDirection,
950        ) -> bool;
951    }
952);
953
954extern_class!(
955    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputstringtokenizer?language=objc)
956    #[unsafe(super(NSObject))]
957    #[thread_kind = MainThreadOnly]
958    #[derive(Debug, PartialEq, Eq, Hash)]
959    pub struct UITextInputStringTokenizer;
960);
961
962extern_conformance!(
963    unsafe impl NSObjectProtocol for UITextInputStringTokenizer {}
964);
965
966extern_conformance!(
967    unsafe impl UITextInputTokenizer for UITextInputStringTokenizer {}
968);
969
970impl UITextInputStringTokenizer {
971    extern_methods!(
972        #[cfg(all(feature = "UIResponder", feature = "UITextInputTraits"))]
973        /// # Safety
974        ///
975        /// `text_input` must implement UITextInput.
976        #[unsafe(method(initWithTextInput:))]
977        #[unsafe(method_family = init)]
978        pub unsafe fn initWithTextInput(
979            this: Allocated<Self>,
980            text_input: &UIResponder,
981        ) -> Retained<Self>;
982    );
983}
984
985/// Methods declared on superclass `NSObject`.
986impl UITextInputStringTokenizer {
987    extern_methods!(
988        #[unsafe(method(init))]
989        #[unsafe(method_family = init)]
990        pub fn init(this: Allocated<Self>) -> Retained<Self>;
991
992        #[unsafe(method(new))]
993        #[unsafe(method_family = new)]
994        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
995    );
996}
997
998extern_class!(
999    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputmode?language=objc)
1000    #[unsafe(super(NSObject))]
1001    #[thread_kind = MainThreadOnly]
1002    #[derive(Debug, PartialEq, Eq, Hash)]
1003    pub struct UITextInputMode;
1004);
1005
1006extern_conformance!(
1007    unsafe impl NSCoding for UITextInputMode {}
1008);
1009
1010extern_conformance!(
1011    unsafe impl NSObjectProtocol for UITextInputMode {}
1012);
1013
1014extern_conformance!(
1015    unsafe impl NSSecureCoding for UITextInputMode {}
1016);
1017
1018impl UITextInputMode {
1019    extern_methods!(
1020        #[unsafe(method(primaryLanguage))]
1021        #[unsafe(method_family = none)]
1022        pub fn primaryLanguage(&self) -> Option<Retained<NSString>>;
1023
1024        #[deprecated]
1025        #[unsafe(method(currentInputMode))]
1026        #[unsafe(method_family = none)]
1027        pub fn currentInputMode(mtm: MainThreadMarker) -> Option<Retained<UITextInputMode>>;
1028
1029        #[unsafe(method(activeInputModes))]
1030        #[unsafe(method_family = none)]
1031        pub fn activeInputModes(mtm: MainThreadMarker) -> Retained<NSArray<UITextInputMode>>;
1032    );
1033}
1034
1035/// Methods declared on superclass `NSObject`.
1036impl UITextInputMode {
1037    extern_methods!(
1038        #[unsafe(method(init))]
1039        #[unsafe(method_family = init)]
1040        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1041
1042        #[unsafe(method(new))]
1043        #[unsafe(method_family = new)]
1044        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
1045    );
1046}
1047
1048extern "C" {
1049    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinputcurrentinputmodedidchangenotification?language=objc)
1050    pub static UITextInputCurrentInputModeDidChangeNotification: &'static NSNotificationName;
1051}