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