objc2_ui_kit/generated/
UITextView.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#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15extern_protocol!(
16    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextviewdelegate?language=objc)
17    #[cfg(feature = "UIScrollView")]
18    pub unsafe trait UITextViewDelegate:
19        NSObjectProtocol + UIScrollViewDelegate + MainThreadOnly
20    {
21        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
22        #[optional]
23        #[unsafe(method(textViewShouldBeginEditing:))]
24        #[unsafe(method_family = none)]
25        fn textViewShouldBeginEditing(&self, text_view: &UITextView) -> bool;
26
27        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
28        #[optional]
29        #[unsafe(method(textViewShouldEndEditing:))]
30        #[unsafe(method_family = none)]
31        fn textViewShouldEndEditing(&self, text_view: &UITextView) -> bool;
32
33        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
34        #[optional]
35        #[unsafe(method(textViewDidBeginEditing:))]
36        #[unsafe(method_family = none)]
37        fn textViewDidBeginEditing(&self, text_view: &UITextView);
38
39        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
40        #[optional]
41        #[unsafe(method(textViewDidEndEditing:))]
42        #[unsafe(method_family = none)]
43        fn textViewDidEndEditing(&self, text_view: &UITextView);
44
45        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
46        #[deprecated]
47        #[optional]
48        #[unsafe(method(textView:shouldChangeTextInRange:replacementText:))]
49        #[unsafe(method_family = none)]
50        fn textView_shouldChangeTextInRange_replacementText(
51            &self,
52            text_view: &UITextView,
53            range: NSRange,
54            text: &NSString,
55        ) -> bool;
56
57        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
58        /// Asks the delegate if the text at the specified `ranges` should be replaced with `text`.
59        ///
60        ///
61        /// If this method returns YES then the text view will, at its own discretion, choose any one of the specified `ranges` of text and replace it with the specified `replacementText` before deleting the text at the other ranges. If the delegate does not implement this method then the `textView:shouldChangeTextInRange:replacementText:` method will be called and passed the union range instead. If the delegate also does not implement that method then YES is assumed.
62        ///
63        ///
64        /// Parameter `textView`: The text view asking the delegate
65        ///
66        /// Parameter `ranges`: The ranges of the text that should be deleted before replacing
67        ///
68        /// Parameter `replacementText`: The replacement text
69        ///
70        ///
71        /// Returns: Returns true if the text at the `ranges` should be replaced.
72        #[optional]
73        #[unsafe(method(textView:shouldChangeTextInRanges:replacementText:))]
74        #[unsafe(method_family = none)]
75        fn textView_shouldChangeTextInRanges_replacementText(
76            &self,
77            text_view: &UITextView,
78            ranges: &NSArray<NSValue>,
79            text: &NSString,
80        ) -> bool;
81
82        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
83        #[optional]
84        #[unsafe(method(textViewDidChange:))]
85        #[unsafe(method_family = none)]
86        fn textViewDidChange(&self, text_view: &UITextView);
87
88        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
89        #[optional]
90        #[unsafe(method(textViewDidChangeSelection:))]
91        #[unsafe(method_family = none)]
92        fn textViewDidChangeSelection(&self, text_view: &UITextView);
93
94        #[cfg(all(
95            feature = "UIMenu",
96            feature = "UIMenuElement",
97            feature = "UIResponder",
98            feature = "UIView"
99        ))]
100        /// Asks the delegate for the menu to be shown for the specified text range.
101        ///
102        ///
103        /// Parameter `textView`: The text view requesting the menu.
104        ///
105        /// Parameter `range`: The text range for which the menu is presented for.
106        ///
107        /// Parameter `suggestedActions`: The actions and commands that the system suggests.
108        ///
109        ///
110        /// Returns: Return a UIMenu describing the desired menu hierarchy. Return
111        /// `nil`to present the default system menu.
112        #[deprecated]
113        #[optional]
114        #[unsafe(method(textView:editMenuForTextInRange:suggestedActions:))]
115        #[unsafe(method_family = none)]
116        fn textView_editMenuForTextInRange_suggestedActions(
117            &self,
118            text_view: &UITextView,
119            range: NSRange,
120            suggested_actions: &NSArray<UIMenuElement>,
121        ) -> Option<Retained<UIMenu>>;
122
123        #[cfg(all(
124            feature = "UIMenu",
125            feature = "UIMenuElement",
126            feature = "UIResponder",
127            feature = "UIView"
128        ))]
129        /// Asks the delegate for the menu to be shown for the specified text ranges.
130        ///
131        ///
132        /// If the delegate does not implement this method then the `textView:editMenuForTextInRange:suggestedActions:` method will be called and passed the union range instead. If the delegate also does not implement that method then `nil` is assumed.
133        ///
134        ///
135        /// Parameter `textView`: The text view requesting the menu.
136        ///
137        /// Parameter `ranges`: The text ranges for which the menu is presented for.
138        ///
139        /// Parameter `suggestedActions`: The actions and commands that the system suggests.
140        ///
141        ///
142        /// Returns: Return a UIMenu describing the desired menu hierarchy. Return
143        /// `nil`to present the default system menu.
144        #[optional]
145        #[unsafe(method(textView:editMenuForTextInRanges:suggestedActions:))]
146        #[unsafe(method_family = none)]
147        fn textView_editMenuForTextInRanges_suggestedActions(
148            &self,
149            text_view: &UITextView,
150            ranges: &NSArray<NSValue>,
151            suggested_actions: &NSArray<UIMenuElement>,
152        ) -> Option<Retained<UIMenu>>;
153
154        #[cfg(all(
155            feature = "UIEditMenuInteraction",
156            feature = "UIResponder",
157            feature = "UIView"
158        ))]
159        /// Called when the text view is about to present the edit menu.
160        ///
161        ///
162        /// Parameter `textView`: The text view displaying the menu.
163        ///
164        /// Parameter `animator`: Appearance animator. Add animations to this object to run them alongside the appearance transition.
165        #[optional]
166        #[unsafe(method(textView:willPresentEditMenuWithAnimator:))]
167        #[unsafe(method_family = none)]
168        fn textView_willPresentEditMenuWithAnimator(
169            &self,
170            text_view: &UITextView,
171            animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
172        );
173
174        #[cfg(all(
175            feature = "UIEditMenuInteraction",
176            feature = "UIResponder",
177            feature = "UIView"
178        ))]
179        /// Called when the text view is about to dismiss the edit menu.
180        ///
181        ///
182        /// Parameter `textView`: The text view displaying the menu.
183        ///
184        /// Parameter `animator`: Dismissal animator. Add animations to this object to run them alongside the dismissal transition.
185        #[optional]
186        #[unsafe(method(textView:willDismissEditMenuWithAnimator:))]
187        #[unsafe(method_family = none)]
188        fn textView_willDismissEditMenuWithAnimator(
189            &self,
190            text_view: &UITextView,
191            animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
192        );
193
194        #[cfg(all(
195            feature = "UIAction",
196            feature = "UIMenuElement",
197            feature = "UIResponder",
198            feature = "UITextItem",
199            feature = "UIView"
200        ))]
201        /// Asks the delegate for the action to be performed when interacting with a text item. If a nil action is provided, the text view
202        /// will request a menu to be presented on primary action if possible.
203        ///
204        ///
205        /// Parameter `textView`: The text view requesting the primary action.
206        ///
207        /// Parameter `textItem`: The text item for performing said action.
208        ///
209        /// Parameter `defaultAction`: The default action for the text item. Return this to perform the default action.
210        ///
211        ///
212        /// Returns: Return a UIAction to be performed when the text item is interacted with. Return
213        /// `nil`to prevent the action from being performed.
214        #[optional]
215        #[unsafe(method(textView:primaryActionForTextItem:defaultAction:))]
216        #[unsafe(method_family = none)]
217        fn textView_primaryActionForTextItem_defaultAction(
218            &self,
219            text_view: &UITextView,
220            text_item: &UITextItem,
221            default_action: &UIAction,
222        ) -> Option<Retained<UIAction>>;
223
224        #[cfg(all(
225            feature = "UIMenu",
226            feature = "UIMenuElement",
227            feature = "UIResponder",
228            feature = "UITextItem",
229            feature = "UIView"
230        ))]
231        /// Asks the delegate for the menu configuration to be performed when interacting with a text item.
232        ///
233        ///
234        /// Parameter `textView`: The text view requesting the menu.
235        ///
236        /// Parameter `textItem`: The text item for performing said action.
237        ///
238        /// Parameter `defaultMenu`: The default menu for the specified text item.
239        ///
240        ///
241        /// Returns: Return a menu configuration to be presented when the text item is interacted with. Return
242        /// `nil`to prevent the menu from being presented.
243        #[optional]
244        #[unsafe(method(textView:menuConfigurationForTextItem:defaultMenu:))]
245        #[unsafe(method_family = none)]
246        fn textView_menuConfigurationForTextItem_defaultMenu(
247            &self,
248            text_view: &UITextView,
249            text_item: &UITextItem,
250            default_menu: &UIMenu,
251        ) -> Option<Retained<UITextItemMenuConfiguration>>;
252
253        #[cfg(all(
254            feature = "UIContextMenuInteraction",
255            feature = "UIResponder",
256            feature = "UITextItem",
257            feature = "UIView"
258        ))]
259        /// Informs the delegate that a text item menu is about to be presented with the specified animator.
260        ///
261        ///
262        /// Parameter `textView`: The text view showing the menu.
263        ///
264        /// Parameter `textItem`: The text item for performing said action.
265        ///
266        /// Parameter `animator`: Appearance animator. Add animations to this object to run them alongside the appearance transition.
267        #[optional]
268        #[unsafe(method(textView:textItemMenuWillDisplayForTextItem:animator:))]
269        #[unsafe(method_family = none)]
270        fn textView_textItemMenuWillDisplayForTextItem_animator(
271            &self,
272            text_view: &UITextView,
273            text_item: &UITextItem,
274            animator: &ProtocolObject<dyn UIContextMenuInteractionAnimating>,
275        );
276
277        #[cfg(all(
278            feature = "UIContextMenuInteraction",
279            feature = "UIResponder",
280            feature = "UITextItem",
281            feature = "UIView"
282        ))]
283        /// Informs the delegate that a text item menu is about to be dismissed with the specified animator.
284        ///
285        ///
286        /// Parameter `textView`: The text view showing the menu.
287        ///
288        /// Parameter `textItem`: The text item for performing said action.
289        ///
290        /// Parameter `animator`: Dismissal animator. Add animations to this object to run them alongside the dismissal transition.
291        #[optional]
292        #[unsafe(method(textView:textItemMenuWillEndForTextItem:animator:))]
293        #[unsafe(method_family = none)]
294        fn textView_textItemMenuWillEndForTextItem_animator(
295            &self,
296            text_view: &UITextView,
297            text_item: &UITextItem,
298            animator: &ProtocolObject<dyn UIContextMenuInteractionAnimating>,
299        );
300
301        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
302        /// Informs the delegate that Writing Tools will begin manipulating the text view
303        ///
304        ///
305        /// Parameter `textView`: The text view interacting with Writing Tools
306        #[optional]
307        #[unsafe(method(textViewWritingToolsWillBegin:))]
308        #[unsafe(method_family = none)]
309        fn textViewWritingToolsWillBegin(&self, text_view: &UITextView);
310
311        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
312        /// Informs the delegate that Writing Tools has finished manipulating the text view
313        ///
314        ///
315        /// Parameter `textView`: The text view interacting with Writing Tools
316        #[optional]
317        #[unsafe(method(textViewWritingToolsDidEnd:))]
318        #[unsafe(method_family = none)]
319        fn textViewWritingToolsDidEnd(&self, text_view: &UITextView);
320
321        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
322        /// Allows the delegate to specify ranges of text to be ignored by Writing Tools
323        ///
324        ///
325        /// Parameter `textView`: The text view interacting with Writing Tools
326        ///
327        /// Parameter `enclosingRange`:
328        ///
329        /// Returns: Return an array of ranges in the attributed substring of the textView storage with the enclosing range representing portions of text to be ignored by Writing Tools when evaluating the text for proofreading, summarization, rewrites, and so forth.
330        #[optional]
331        #[unsafe(method(textView:writingToolsIgnoredRangesInEnclosingRange:))]
332        #[unsafe(method_family = none)]
333        fn textView_writingToolsIgnoredRangesInEnclosingRange(
334            &self,
335            text_view: &UITextView,
336            enclosing_range: NSRange,
337        ) -> Retained<NSArray<NSValue>>;
338
339        #[cfg(all(
340            feature = "UIResponder",
341            feature = "UITextItemInteraction",
342            feature = "UIView"
343        ))]
344        #[deprecated = "Replaced by primaryActionForTextItem: and menuConfigurationForTextItem: for additional customization options."]
345        #[optional]
346        #[unsafe(method(textView:shouldInteractWithURL:inRange:interaction:))]
347        #[unsafe(method_family = none)]
348        fn textView_shouldInteractWithURL_inRange_interaction(
349            &self,
350            text_view: &UITextView,
351            url: &NSURL,
352            character_range: NSRange,
353            interaction: UITextItemInteraction,
354        ) -> bool;
355
356        #[cfg(all(
357            feature = "NSTextAttachment",
358            feature = "UIResponder",
359            feature = "UITextItemInteraction",
360            feature = "UIView"
361        ))]
362        #[deprecated = "Replaced by primaryActionForTextItem: and menuConfigurationForTextItem: for additional customization options."]
363        #[optional]
364        #[unsafe(method(textView:shouldInteractWithTextAttachment:inRange:interaction:))]
365        #[unsafe(method_family = none)]
366        fn textView_shouldInteractWithTextAttachment_inRange_interaction(
367            &self,
368            text_view: &UITextView,
369            text_attachment: &NSTextAttachment,
370            character_range: NSRange,
371            interaction: UITextItemInteraction,
372        ) -> bool;
373
374        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
375        #[deprecated]
376        #[optional]
377        #[unsafe(method(textView:shouldInteractWithURL:inRange:))]
378        #[unsafe(method_family = none)]
379        fn textView_shouldInteractWithURL_inRange(
380            &self,
381            text_view: &UITextView,
382            url: &NSURL,
383            character_range: NSRange,
384        ) -> bool;
385
386        #[cfg(all(
387            feature = "NSTextAttachment",
388            feature = "UIResponder",
389            feature = "UIView"
390        ))]
391        #[deprecated]
392        #[optional]
393        #[unsafe(method(textView:shouldInteractWithTextAttachment:inRange:))]
394        #[unsafe(method_family = none)]
395        fn textView_shouldInteractWithTextAttachment_inRange(
396            &self,
397            text_view: &UITextView,
398            text_attachment: &NSTextAttachment,
399            character_range: NSRange,
400        ) -> bool;
401
402        #[cfg(all(
403            feature = "UIResponder",
404            feature = "UITextFormattingViewController",
405            feature = "UIView",
406            feature = "UIViewController"
407        ))]
408        /// Informs the delegate that text formatting controller is about to be presented.
409        ///
410        ///
411        /// Parameter `viewController`: The text formatting controller that is being presented.
412        #[optional]
413        #[unsafe(method(textView:willBeginFormattingWithViewController:))]
414        #[unsafe(method_family = none)]
415        fn textView_willBeginFormattingWithViewController(
416            &self,
417            text_view: &UITextView,
418            view_controller: &UITextFormattingViewController,
419        );
420
421        #[cfg(all(
422            feature = "UIResponder",
423            feature = "UITextFormattingViewController",
424            feature = "UIView",
425            feature = "UIViewController"
426        ))]
427        /// Informs the delegate that text formatting controller has been presented.
428        ///
429        ///
430        /// Parameter `viewController`: The text formatting controller that is being presented.
431        #[optional]
432        #[unsafe(method(textView:didBeginFormattingWithViewController:))]
433        #[unsafe(method_family = none)]
434        fn textView_didBeginFormattingWithViewController(
435            &self,
436            text_view: &UITextView,
437            view_controller: &UITextFormattingViewController,
438        );
439
440        #[cfg(all(
441            feature = "UIResponder",
442            feature = "UITextFormattingViewController",
443            feature = "UIView",
444            feature = "UIViewController"
445        ))]
446        /// Informs the delegate that text formatting controller is about to be dismissed.
447        ///
448        ///
449        /// Parameter `viewController`: The text formatting controller that is being presented.
450        #[optional]
451        #[unsafe(method(textView:willEndFormattingWithViewController:))]
452        #[unsafe(method_family = none)]
453        fn textView_willEndFormattingWithViewController(
454            &self,
455            text_view: &UITextView,
456            view_controller: &UITextFormattingViewController,
457        );
458
459        #[cfg(all(
460            feature = "UIResponder",
461            feature = "UITextFormattingViewController",
462            feature = "UIView",
463            feature = "UIViewController"
464        ))]
465        /// Informs the delegate that text formatting controller has been dismissed.
466        ///
467        ///
468        /// Parameter `viewController`: The text formatting controller that is being presented.
469        #[optional]
470        #[unsafe(method(textView:didEndFormattingWithViewController:))]
471        #[unsafe(method_family = none)]
472        fn textView_didEndFormattingWithViewController(
473            &self,
474            text_view: &UITextView,
475            view_controller: &UITextFormattingViewController,
476        );
477
478        #[cfg(all(
479            feature = "UIInputSuggestion",
480            feature = "UIResponder",
481            feature = "UIView"
482        ))]
483        /// Tells the delegate when the keyboard delivers an input suggestion.
484        ///
485        /// - Parameters:
486        /// - textView: The text view that is currently the first responder.
487        /// - inputSuggestion: The input suggestion that the user or system selected.
488        #[optional]
489        #[unsafe(method(textView:insertInputSuggestion:))]
490        #[unsafe(method_family = none)]
491        fn textView_insertInputSuggestion(
492            &self,
493            text_view: &UITextView,
494            input_suggestion: &UIInputSuggestion,
495        );
496    }
497);
498
499/// The type of border around the text view.
500///
501/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextviewborderstyle?language=objc)
502// NS_ENUM
503#[repr(transparent)]
504#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
505pub struct UITextViewBorderStyle(pub NSInteger);
506impl UITextViewBorderStyle {
507    /// The text view does not display a border.
508    #[doc(alias = "UITextViewBorderStyleNone")]
509    pub const None: Self = Self(0);
510    /// Displays a rounded-style border for the text view.
511    #[doc(alias = "UITextViewBorderStyleRoundedRect")]
512    pub const RoundedRect: Self = Self(1);
513}
514
515unsafe impl Encode for UITextViewBorderStyle {
516    const ENCODING: Encoding = NSInteger::ENCODING;
517}
518
519unsafe impl RefEncode for UITextViewBorderStyle {
520    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
521}
522
523extern_class!(
524    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextview?language=objc)
525    #[unsafe(super(UIScrollView, UIView, UIResponder, NSObject))]
526    #[thread_kind = MainThreadOnly]
527    #[derive(Debug, PartialEq, Eq, Hash)]
528    #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
529    pub struct UITextView;
530);
531
532#[cfg(all(
533    feature = "UIResponder",
534    feature = "UIScrollView",
535    feature = "UIView",
536    feature = "objc2-quartz-core"
537))]
538#[cfg(not(target_os = "watchos"))]
539extern_conformance!(
540    unsafe impl CALayerDelegate for UITextView {}
541);
542
543#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
544extern_conformance!(
545    unsafe impl NSCoding for UITextView {}
546);
547
548#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
549extern_conformance!(
550    unsafe impl NSObjectProtocol for UITextView {}
551);
552
553#[cfg(all(
554    feature = "UIAppearance",
555    feature = "UIResponder",
556    feature = "UIScrollView",
557    feature = "UIView"
558))]
559extern_conformance!(
560    unsafe impl UIAppearance for UITextView {}
561);
562
563#[cfg(all(
564    feature = "UIAppearance",
565    feature = "UIResponder",
566    feature = "UIScrollView",
567    feature = "UIView"
568))]
569extern_conformance!(
570    unsafe impl UIAppearanceContainer for UITextView {}
571);
572
573#[cfg(all(
574    feature = "UIContentSizeCategoryAdjusting",
575    feature = "UIResponder",
576    feature = "UIScrollView",
577    feature = "UIView"
578))]
579extern_conformance!(
580    unsafe impl UIContentSizeCategoryAdjusting for UITextView {}
581);
582
583#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
584extern_conformance!(
585    unsafe impl UICoordinateSpace for UITextView {}
586);
587
588#[cfg(all(
589    feature = "UIDynamicBehavior",
590    feature = "UIResponder",
591    feature = "UIScrollView",
592    feature = "UIView"
593))]
594extern_conformance!(
595    unsafe impl UIDynamicItem for UITextView {}
596);
597
598#[cfg(all(
599    feature = "UIFocus",
600    feature = "UIResponder",
601    feature = "UIScrollView",
602    feature = "UIView"
603))]
604extern_conformance!(
605    unsafe impl UIFocusEnvironment for UITextView {}
606);
607
608#[cfg(all(
609    feature = "UIFocus",
610    feature = "UIResponder",
611    feature = "UIScrollView",
612    feature = "UIView"
613))]
614extern_conformance!(
615    unsafe impl UIFocusItem for UITextView {}
616);
617
618#[cfg(all(
619    feature = "UIFocus",
620    feature = "UIResponder",
621    feature = "UIScrollView",
622    feature = "UIView"
623))]
624extern_conformance!(
625    unsafe impl UIFocusItemContainer for UITextView {}
626);
627
628#[cfg(all(
629    feature = "UIFocus",
630    feature = "UIResponder",
631    feature = "UIScrollView",
632    feature = "UIView"
633))]
634extern_conformance!(
635    unsafe impl UIFocusItemScrollableContainer for UITextView {}
636);
637
638#[cfg(all(
639    feature = "UIResponder",
640    feature = "UIScrollView",
641    feature = "UITextInput",
642    feature = "UITextInputTraits",
643    feature = "UIView"
644))]
645extern_conformance!(
646    unsafe impl UIKeyInput for UITextView {}
647);
648
649#[cfg(all(
650    feature = "UILetterformAwareAdjusting",
651    feature = "UIResponder",
652    feature = "UIScrollView",
653    feature = "UIView"
654))]
655extern_conformance!(
656    unsafe impl UILetterformAwareAdjusting for UITextView {}
657);
658
659#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
660extern_conformance!(
661    unsafe impl UIResponderStandardEditActions for UITextView {}
662);
663
664#[cfg(all(
665    feature = "UIResponder",
666    feature = "UIScrollView",
667    feature = "UITextInput",
668    feature = "UITextInputTraits",
669    feature = "UIView"
670))]
671extern_conformance!(
672    unsafe impl UITextInput for UITextView {}
673);
674
675#[cfg(all(
676    feature = "UIResponder",
677    feature = "UIScrollView",
678    feature = "UITextInputTraits",
679    feature = "UIView"
680))]
681extern_conformance!(
682    unsafe impl UITextInputTraits for UITextView {}
683);
684
685#[cfg(all(
686    feature = "UIResponder",
687    feature = "UIScrollView",
688    feature = "UITraitCollection",
689    feature = "UIView"
690))]
691extern_conformance!(
692    unsafe impl UITraitEnvironment for UITextView {}
693);
694
695#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
696impl UITextView {
697    extern_methods!(
698        #[unsafe(method(delegate))]
699        #[unsafe(method_family = none)]
700        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UITextViewDelegate>>>;
701
702        /// Setter for [`delegate`][Self::delegate].
703        ///
704        /// This is a [weak property][objc2::topics::weak_property].
705        #[unsafe(method(setDelegate:))]
706        #[unsafe(method_family = none)]
707        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UITextViewDelegate>>);
708
709        #[unsafe(method(text))]
710        #[unsafe(method_family = none)]
711        pub fn text(&self) -> Retained<NSString>;
712
713        /// Setter for [`text`][Self::text].
714        ///
715        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
716        #[unsafe(method(setText:))]
717        #[unsafe(method_family = none)]
718        pub fn setText(&self, text: Option<&NSString>);
719
720        #[cfg(feature = "UIFont")]
721        #[unsafe(method(font))]
722        #[unsafe(method_family = none)]
723        pub fn font(&self) -> Option<Retained<UIFont>>;
724
725        #[cfg(feature = "UIFont")]
726        /// Setter for [`font`][Self::font].
727        #[unsafe(method(setFont:))]
728        #[unsafe(method_family = none)]
729        pub fn setFont(&self, font: Option<&UIFont>);
730
731        #[cfg(feature = "UIColor")]
732        #[unsafe(method(textColor))]
733        #[unsafe(method_family = none)]
734        pub fn textColor(&self) -> Option<Retained<UIColor>>;
735
736        #[cfg(feature = "UIColor")]
737        /// Setter for [`textColor`][Self::textColor].
738        #[unsafe(method(setTextColor:))]
739        #[unsafe(method_family = none)]
740        pub fn setTextColor(&self, text_color: Option<&UIColor>);
741
742        #[cfg(feature = "NSText")]
743        #[unsafe(method(textAlignment))]
744        #[unsafe(method_family = none)]
745        pub fn textAlignment(&self) -> NSTextAlignment;
746
747        #[cfg(feature = "NSText")]
748        /// Setter for [`textAlignment`][Self::textAlignment].
749        #[unsafe(method(setTextAlignment:))]
750        #[unsafe(method_family = none)]
751        pub fn setTextAlignment(&self, text_alignment: NSTextAlignment);
752
753        /// A union of all the `selectedRanges`.
754        #[deprecated]
755        #[unsafe(method(selectedRange))]
756        #[unsafe(method_family = none)]
757        pub fn selectedRange(&self) -> NSRange;
758
759        /// Setter for [`selectedRange`][Self::selectedRange].
760        #[deprecated]
761        #[unsafe(method(setSelectedRange:))]
762        #[unsafe(method_family = none)]
763        pub fn setSelectedRange(&self, selected_range: NSRange);
764
765        /// The `NSRange`s of the selection. In most cases, there will only be a single selected range. For cases where bidirectional text is selected, there may be multiple discontiguous ranges. These selected ranges will always be in the normal form, which means they are sorted in ascending order and there are no overlaps. The selected ranges will always be converted to its normal form when they are set. There will always be at least one selected range in this array. So if this array is set to an empty array then the selection will be cleared and a single selected range will be left behind where the length will be 0 and the location will be the location at the end of the selection.
766        #[unsafe(method(selectedRanges))]
767        #[unsafe(method_family = none)]
768        pub fn selectedRanges(&self) -> Retained<NSArray<NSValue>>;
769
770        /// Setter for [`selectedRanges`][Self::selectedRanges].
771        ///
772        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
773        #[unsafe(method(setSelectedRanges:))]
774        #[unsafe(method_family = none)]
775        pub fn setSelectedRanges(&self, selected_ranges: &NSArray<NSValue>);
776
777        #[unsafe(method(isEditable))]
778        #[unsafe(method_family = none)]
779        pub fn isEditable(&self) -> bool;
780
781        /// Setter for [`isEditable`][Self::isEditable].
782        #[unsafe(method(setEditable:))]
783        #[unsafe(method_family = none)]
784        pub fn setEditable(&self, editable: bool);
785
786        #[unsafe(method(isSelectable))]
787        #[unsafe(method_family = none)]
788        pub fn isSelectable(&self) -> bool;
789
790        /// Setter for [`isSelectable`][Self::isSelectable].
791        #[unsafe(method(setSelectable:))]
792        #[unsafe(method_family = none)]
793        pub fn setSelectable(&self, selectable: bool);
794
795        #[cfg(feature = "UIDataDetectors")]
796        #[unsafe(method(dataDetectorTypes))]
797        #[unsafe(method_family = none)]
798        pub fn dataDetectorTypes(&self) -> UIDataDetectorTypes;
799
800        #[cfg(feature = "UIDataDetectors")]
801        /// Setter for [`dataDetectorTypes`][Self::dataDetectorTypes].
802        #[unsafe(method(setDataDetectorTypes:))]
803        #[unsafe(method_family = none)]
804        pub fn setDataDetectorTypes(&self, data_detector_types: UIDataDetectorTypes);
805
806        #[unsafe(method(allowsEditingTextAttributes))]
807        #[unsafe(method_family = none)]
808        pub fn allowsEditingTextAttributes(&self) -> bool;
809
810        /// Setter for [`allowsEditingTextAttributes`][Self::allowsEditingTextAttributes].
811        #[unsafe(method(setAllowsEditingTextAttributes:))]
812        #[unsafe(method_family = none)]
813        pub fn setAllowsEditingTextAttributes(&self, allows_editing_text_attributes: bool);
814
815        #[unsafe(method(attributedText))]
816        #[unsafe(method_family = none)]
817        pub fn attributedText(&self) -> Retained<NSAttributedString>;
818
819        /// Setter for [`attributedText`][Self::attributedText].
820        ///
821        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
822        #[unsafe(method(setAttributedText:))]
823        #[unsafe(method_family = none)]
824        pub fn setAttributedText(&self, attributed_text: Option<&NSAttributedString>);
825
826        #[unsafe(method(typingAttributes))]
827        #[unsafe(method_family = none)]
828        pub fn typingAttributes(&self) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
829
830        /// Setter for [`typingAttributes`][Self::typingAttributes].
831        ///
832        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
833        ///
834        /// # Safety
835        ///
836        /// `typing_attributes` generic should be of the correct type.
837        #[unsafe(method(setTypingAttributes:))]
838        #[unsafe(method_family = none)]
839        pub unsafe fn setTypingAttributes(
840            &self,
841            typing_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
842        );
843
844        #[unsafe(method(scrollRangeToVisible:))]
845        #[unsafe(method_family = none)]
846        pub fn scrollRangeToVisible(&self, range: NSRange);
847
848        #[unsafe(method(inputView))]
849        #[unsafe(method_family = none)]
850        pub fn inputView(&self) -> Option<Retained<UIView>>;
851
852        /// Setter for [`inputView`][Self::inputView].
853        #[unsafe(method(setInputView:))]
854        #[unsafe(method_family = none)]
855        pub fn setInputView(&self, input_view: Option<&UIView>);
856
857        #[unsafe(method(inputAccessoryView))]
858        #[unsafe(method_family = none)]
859        pub fn inputAccessoryView(&self) -> Option<Retained<UIView>>;
860
861        /// Setter for [`inputAccessoryView`][Self::inputAccessoryView].
862        #[unsafe(method(setInputAccessoryView:))]
863        #[unsafe(method_family = none)]
864        pub fn setInputAccessoryView(&self, input_accessory_view: Option<&UIView>);
865
866        #[unsafe(method(clearsOnInsertion))]
867        #[unsafe(method_family = none)]
868        pub fn clearsOnInsertion(&self) -> bool;
869
870        /// Setter for [`clearsOnInsertion`][Self::clearsOnInsertion].
871        #[unsafe(method(setClearsOnInsertion:))]
872        #[unsafe(method_family = none)]
873        pub fn setClearsOnInsertion(&self, clears_on_insertion: bool);
874
875        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
876        #[unsafe(method(initWithFrame:textContainer:))]
877        #[unsafe(method_family = init)]
878        pub fn initWithFrame_textContainer(
879            this: Allocated<Self>,
880            frame: CGRect,
881            text_container: Option<&NSTextContainer>,
882        ) -> Retained<Self>;
883
884        #[unsafe(method(textViewUsingTextLayoutManager:))]
885        #[unsafe(method_family = none)]
886        pub fn textViewUsingTextLayoutManager(
887            using_text_layout_manager: bool,
888            mtm: MainThreadMarker,
889        ) -> Retained<Self>;
890
891        /// # Safety
892        ///
893        /// `coder` possibly has further requirements.
894        #[unsafe(method(initWithCoder:))]
895        #[unsafe(method_family = init)]
896        pub unsafe fn initWithCoder(
897            this: Allocated<Self>,
898            coder: &NSCoder,
899        ) -> Option<Retained<Self>>;
900
901        #[cfg(feature = "NSTextContainer")]
902        #[unsafe(method(textContainer))]
903        #[unsafe(method_family = none)]
904        pub fn textContainer(&self) -> Retained<NSTextContainer>;
905
906        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
907        #[unsafe(method(textContainerInset))]
908        #[unsafe(method_family = none)]
909        pub fn textContainerInset(&self) -> UIEdgeInsets;
910
911        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
912        /// Setter for [`textContainerInset`][Self::textContainerInset].
913        #[unsafe(method(setTextContainerInset:))]
914        #[unsafe(method_family = none)]
915        pub fn setTextContainerInset(&self, text_container_inset: UIEdgeInsets);
916
917        #[cfg(feature = "NSTextLayoutManager")]
918        #[unsafe(method(textLayoutManager))]
919        #[unsafe(method_family = none)]
920        pub fn textLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;
921
922        #[cfg(feature = "NSLayoutManager")]
923        #[unsafe(method(layoutManager))]
924        #[unsafe(method_family = none)]
925        pub fn layoutManager(&self) -> Retained<NSLayoutManager>;
926
927        #[cfg(feature = "NSTextStorage")]
928        #[unsafe(method(textStorage))]
929        #[unsafe(method_family = none)]
930        pub fn textStorage(&self) -> Retained<NSTextStorage>;
931
932        #[unsafe(method(linkTextAttributes))]
933        #[unsafe(method_family = none)]
934        pub fn linkTextAttributes(
935            &self,
936        ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
937
938        /// Setter for [`linkTextAttributes`][Self::linkTextAttributes].
939        ///
940        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
941        ///
942        /// # Safety
943        ///
944        /// `link_text_attributes` generic should be of the correct type.
945        #[unsafe(method(setLinkTextAttributes:))]
946        #[unsafe(method_family = none)]
947        pub unsafe fn setLinkTextAttributes(
948            &self,
949            link_text_attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
950        );
951
952        #[unsafe(method(usesStandardTextScaling))]
953        #[unsafe(method_family = none)]
954        pub fn usesStandardTextScaling(&self) -> bool;
955
956        /// Setter for [`usesStandardTextScaling`][Self::usesStandardTextScaling].
957        #[unsafe(method(setUsesStandardTextScaling:))]
958        #[unsafe(method_family = none)]
959        pub fn setUsesStandardTextScaling(&self, uses_standard_text_scaling: bool);
960
961        #[cfg(feature = "UIFindInteraction")]
962        /// If `findInteractionEnabled` is set to true, returns this text view's built-in find interaction. Otherwise, nil.
963        #[unsafe(method(findInteraction))]
964        #[unsafe(method_family = none)]
965        pub fn findInteraction(&self) -> Option<Retained<UIFindInteraction>>;
966
967        /// Enables this text view's built-in find interaction.
968        #[unsafe(method(isFindInteractionEnabled))]
969        #[unsafe(method_family = none)]
970        pub fn isFindInteractionEnabled(&self) -> bool;
971
972        /// Setter for [`isFindInteractionEnabled`][Self::isFindInteractionEnabled].
973        #[unsafe(method(setFindInteractionEnabled:))]
974        #[unsafe(method_family = none)]
975        pub fn setFindInteractionEnabled(&self, find_interaction_enabled: bool);
976
977        /// The border style for the text field.
978        #[unsafe(method(borderStyle))]
979        #[unsafe(method_family = none)]
980        pub fn borderStyle(&self) -> UITextViewBorderStyle;
981
982        /// Setter for [`borderStyle`][Self::borderStyle].
983        #[unsafe(method(setBorderStyle:))]
984        #[unsafe(method_family = none)]
985        pub fn setBorderStyle(&self, border_style: UITextViewBorderStyle);
986
987        #[unsafe(method(textHighlightAttributes))]
988        #[unsafe(method_family = none)]
989        pub fn textHighlightAttributes(
990            &self,
991        ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
992
993        /// Setter for [`textHighlightAttributes`][Self::textHighlightAttributes].
994        ///
995        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
996        ///
997        /// # Safety
998        ///
999        /// `text_highlight_attributes` generic should be of the correct type.
1000        #[unsafe(method(setTextHighlightAttributes:))]
1001        #[unsafe(method_family = none)]
1002        pub unsafe fn setTextHighlightAttributes(
1003            &self,
1004            text_highlight_attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
1005        );
1006
1007        #[cfg(all(feature = "NSTextRange", feature = "objc2-core-foundation"))]
1008        #[unsafe(method(drawTextHighlightBackgroundForTextRange:origin:))]
1009        #[unsafe(method_family = none)]
1010        pub fn drawTextHighlightBackgroundForTextRange_origin(
1011            &self,
1012            text_range: &NSTextRange,
1013            origin: CGPoint,
1014        );
1015
1016        /// Convenience for tracking whether Writing Tools is active
1017        ///
1018        ///
1019        /// Returns: Returns
1020        /// `YES`while Writing Tools is interacting with the receiver (after
1021        /// `-textViewWritingToolsWillBegin:`completes until
1022        /// `-textViewWritingToolsDidEnd:`completes)
1023        #[unsafe(method(isWritingToolsActive))]
1024        #[unsafe(method_family = none)]
1025        pub fn isWritingToolsActive(&self) -> bool;
1026
1027        #[cfg(feature = "UITextInputTraits")]
1028        #[unsafe(method(writingToolsBehavior))]
1029        #[unsafe(method_family = none)]
1030        pub fn writingToolsBehavior(&self) -> UIWritingToolsBehavior;
1031
1032        #[cfg(feature = "UITextInputTraits")]
1033        /// Setter for [`writingToolsBehavior`][Self::writingToolsBehavior].
1034        #[unsafe(method(setWritingToolsBehavior:))]
1035        #[unsafe(method_family = none)]
1036        pub fn setWritingToolsBehavior(&self, writing_tools_behavior: UIWritingToolsBehavior);
1037
1038        #[cfg(feature = "UITextInputTraits")]
1039        #[unsafe(method(allowedWritingToolsResultOptions))]
1040        #[unsafe(method_family = none)]
1041        pub fn allowedWritingToolsResultOptions(&self) -> UIWritingToolsResultOptions;
1042
1043        #[cfg(feature = "UITextInputTraits")]
1044        /// Setter for [`allowedWritingToolsResultOptions`][Self::allowedWritingToolsResultOptions].
1045        #[unsafe(method(setAllowedWritingToolsResultOptions:))]
1046        #[unsafe(method_family = none)]
1047        pub fn setAllowedWritingToolsResultOptions(
1048            &self,
1049            allowed_writing_tools_result_options: UIWritingToolsResultOptions,
1050        );
1051
1052        #[unsafe(method(subclassForWritingToolsCoordinator))]
1053        #[unsafe(method_family = none)]
1054        pub fn subclassForWritingToolsCoordinator(&self) -> &'static AnyClass;
1055
1056        #[cfg(feature = "UIWritingToolsCoordinator")]
1057        #[unsafe(method(writingToolsCoordinator))]
1058        #[unsafe(method_family = none)]
1059        pub fn writingToolsCoordinator(&self) -> Retained<UIWritingToolsCoordinator>;
1060
1061        #[cfg(feature = "UITextFormattingViewControllerConfiguration")]
1062        /// For text views that have flag `allowsEditingTextAttributes` set,
1063        /// this configuration will be used for `UITextFormattingViewController`
1064        /// when its presentation is requested.
1065        ///
1066        /// It has a non-nil default value.
1067        #[unsafe(method(textFormattingConfiguration))]
1068        #[unsafe(method_family = none)]
1069        pub fn textFormattingConfiguration(
1070            &self,
1071        ) -> Option<Retained<UITextFormattingViewControllerConfiguration>>;
1072
1073        #[cfg(feature = "UITextFormattingViewControllerConfiguration")]
1074        /// Setter for [`textFormattingConfiguration`][Self::textFormattingConfiguration].
1075        ///
1076        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1077        #[unsafe(method(setTextFormattingConfiguration:))]
1078        #[unsafe(method_family = none)]
1079        pub fn setTextFormattingConfiguration(
1080            &self,
1081            text_formatting_configuration: Option<&UITextFormattingViewControllerConfiguration>,
1082        );
1083    );
1084}
1085
1086/// Methods declared on superclass `UIView`.
1087#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1088impl UITextView {
1089    extern_methods!(
1090        #[cfg(feature = "objc2-core-foundation")]
1091        #[unsafe(method(initWithFrame:))]
1092        #[unsafe(method_family = init)]
1093        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
1094
1095        #[unsafe(method(init))]
1096        #[unsafe(method_family = init)]
1097        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1098    );
1099}
1100
1101/// Methods declared on superclass `NSObject`.
1102#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1103impl UITextView {
1104    extern_methods!(
1105        #[unsafe(method(new))]
1106        #[unsafe(method_family = new)]
1107        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
1108    );
1109}
1110
1111#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1112impl UITextView {
1113    extern_methods!();
1114}
1115
1116#[cfg(all(
1117    feature = "UIFindInteraction",
1118    feature = "UIResponder",
1119    feature = "UIScrollView",
1120    feature = "UIView"
1121))]
1122extern_conformance!(
1123    unsafe impl UIFindInteractionDelegate for UITextView {}
1124);
1125
1126#[cfg(all(
1127    feature = "UIResponder",
1128    feature = "UIScrollView",
1129    feature = "UITextDragging",
1130    feature = "UITextInput",
1131    feature = "UITextInputTraits",
1132    feature = "UIView"
1133))]
1134extern_conformance!(
1135    unsafe impl UITextDraggable for UITextView {}
1136);
1137
1138#[cfg(all(
1139    feature = "UIPasteConfigurationSupporting",
1140    feature = "UIResponder",
1141    feature = "UIScrollView",
1142    feature = "UITextDropping",
1143    feature = "UITextInput",
1144    feature = "UITextInputTraits",
1145    feature = "UITextPasteConfigurationSupporting",
1146    feature = "UIView"
1147))]
1148extern_conformance!(
1149    unsafe impl UITextDroppable for UITextView {}
1150);
1151
1152#[cfg(all(
1153    feature = "UIPasteConfigurationSupporting",
1154    feature = "UIResponder",
1155    feature = "UIScrollView",
1156    feature = "UITextPasteConfigurationSupporting",
1157    feature = "UIView"
1158))]
1159extern_conformance!(
1160    unsafe impl UITextPasteConfigurationSupporting for UITextView {}
1161);
1162
1163#[cfg(all(
1164    feature = "UIResponder",
1165    feature = "UIScrollView",
1166    feature = "UITextSearching",
1167    feature = "UIView"
1168))]
1169extern_conformance!(
1170    unsafe impl UITextSearching for UITextView {}
1171);
1172
1173/// UIInteractionStateRestorable.
1174#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1175impl UITextView {
1176    extern_methods!(
1177        #[unsafe(method(interactionState))]
1178        #[unsafe(method_family = none)]
1179        pub fn interactionState(&self) -> Retained<AnyObject>;
1180
1181        /// Setter for [`interactionState`][Self::interactionState].
1182        ///
1183        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1184        ///
1185        /// # Safety
1186        ///
1187        /// `interaction_state` should be of the correct type.
1188        #[unsafe(method(setInteractionState:))]
1189        #[unsafe(method_family = none)]
1190        pub unsafe fn setInteractionState(&self, interaction_state: &AnyObject);
1191    );
1192}
1193
1194extern "C" {
1195    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextviewtextdidbegineditingnotification?language=objc)
1196    pub static UITextViewTextDidBeginEditingNotification: &'static NSNotificationName;
1197}
1198
1199extern "C" {
1200    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextviewtextdidchangenotification?language=objc)
1201    pub static UITextViewTextDidChangeNotification: &'static NSNotificationName;
1202}
1203
1204extern "C" {
1205    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextviewtextdidendeditingnotification?language=objc)
1206    pub static UITextViewTextDidEndEditingNotification: &'static NSNotificationName;
1207}