objc2_ui_kit/generated/
UITextSelectionDisplayInteraction.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextselectiondisplayinteractiondelegate?language=objc)
12    pub unsafe trait UITextSelectionDisplayInteractionDelegate:
13        NSObjectProtocol + MainThreadOnly
14    {
15        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
16        /// If different than the view that the interaction is installed onto, one can return a container view here for
17        /// selection views that draw _below_ text. Includes selection highlight view, etc. The default is assumed
18        /// that all views are to be installed onto the interaction's view.
19        #[optional]
20        #[unsafe(method(selectionContainerViewBelowTextForSelectionDisplayInteraction:))]
21        #[unsafe(method_family = none)]
22        unsafe fn selectionContainerViewBelowTextForSelectionDisplayInteraction(
23            &self,
24            interaction: &UITextSelectionDisplayInteraction,
25        ) -> Option<Retained<UIView>>;
26    }
27);
28
29extern_class!(
30    /// Manages a collection of selection views (cursor, highlight, range adjustment) for a particular UITextInput object.
31    ///
32    /// This is the component that
33    /// `UITextInteraction`generally talks to in order to accomplish all selection display
34    /// using a collection of "managed subviews", i.e., selection view components that actually manage the display of the selection
35    /// and the various affordances for changing the selection.
36    ///
37    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextselectiondisplayinteraction?language=objc)
38    #[unsafe(super(NSObject))]
39    #[thread_kind = MainThreadOnly]
40    #[derive(Debug, PartialEq, Eq, Hash)]
41    pub struct UITextSelectionDisplayInteraction;
42);
43
44unsafe impl NSObjectProtocol for UITextSelectionDisplayInteraction {}
45
46#[cfg(feature = "UIInteraction")]
47unsafe impl UIInteraction for UITextSelectionDisplayInteraction {}
48
49impl UITextSelectionDisplayInteraction {
50    extern_methods!(
51        /// Controls both the hidden sate of contained selection views as well as interactions that follow.
52        #[unsafe(method(isActivated))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn isActivated(&self) -> bool;
55
56        /// Setter for [`isActivated`][Self::isActivated].
57        #[unsafe(method(setActivated:))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn setActivated(&self, activated: bool);
60
61        #[cfg(all(feature = "UITextInput", feature = "UITextInputTraits"))]
62        /// The object the selection is being managed for.
63        #[unsafe(method(textInput))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn textInput(&self) -> Option<Retained<ProtocolObject<dyn UITextInput>>>;
66
67        /// See
68        /// `UITextSelectionDisplayInteractionDelegate.`
69        #[unsafe(method(delegate))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn delegate(
72            &self,
73        ) -> Option<Retained<ProtocolObject<dyn UITextSelectionDisplayInteractionDelegate>>>;
74
75        #[cfg(all(
76            feature = "UIResponder",
77            feature = "UITextCursorView",
78            feature = "UIView"
79        ))]
80        /// The cursor view (also known as "caret" view). Shown when the selection is not ranged.
81        #[unsafe(method(cursorView))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn cursorView(&self) -> Retained<UIView>;
84
85        #[cfg(all(
86            feature = "UIResponder",
87            feature = "UITextCursorView",
88            feature = "UIView"
89        ))]
90        /// Setter for [`cursorView`][Self::cursorView].
91        #[unsafe(method(setCursorView:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn setCursorView(&self, cursor_view: &UIView);
94
95        #[cfg(all(
96            feature = "UIResponder",
97            feature = "UITextSelectionHighlightView",
98            feature = "UIView"
99        ))]
100        /// The highlight view. This is the blue/tinted highlight drawn behind the rendered text.
101        #[unsafe(method(highlightView))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn highlightView(&self) -> Retained<UIView>;
104
105        #[cfg(all(
106            feature = "UIResponder",
107            feature = "UITextSelectionHighlightView",
108            feature = "UIView"
109        ))]
110        /// Setter for [`highlightView`][Self::highlightView].
111        #[unsafe(method(setHighlightView:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setHighlightView(&self, highlight_view: &UIView);
114
115        #[cfg(all(
116            feature = "UIResponder",
117            feature = "UITextSelectionHandleView",
118            feature = "UIView"
119        ))]
120        /// The selection handles, shown adjacent to the highlight view's
121        /// `selectionRects`when the selection is ranged.
122        ///
123        /// If you are replacing these system-provided handle views with your own, you must provide exactly two handle views, one to be used as the leading handle,
124        /// and another to be used as the trailing handle.
125        #[unsafe(method(handleViews))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn handleViews(&self) -> Retained<NSArray<UIView>>;
128
129        #[cfg(all(
130            feature = "UIResponder",
131            feature = "UITextSelectionHandleView",
132            feature = "UIView"
133        ))]
134        /// Setter for [`handleViews`][Self::handleViews].
135        #[unsafe(method(setHandleViews:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setHandleViews(&self, handle_views: &NSArray<UIView>);
138
139        #[cfg(all(feature = "UITextInput", feature = "UITextInputTraits"))]
140        /// Creates a UITextSelectionDisplayInteractionDelegate for a given object that implements the UITextInput protocol.
141        /// `textInput` may be the same as the view this interaction is installed onto.
142        #[unsafe(method(initWithTextInput:delegate:))]
143        #[unsafe(method_family = init)]
144        pub unsafe fn initWithTextInput_delegate(
145            this: Allocated<Self>,
146            text_input: &ProtocolObject<dyn UITextInput>,
147            delegate: &ProtocolObject<dyn UITextSelectionDisplayInteractionDelegate>,
148        ) -> Retained<Self>;
149
150        /// Loads the selection from `-[UITextInput selectedTextRange]` and applies the selection to all managed subviews.
151        #[unsafe(method(layoutManagedSubviews))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn layoutManagedSubviews(&self);
154
155        /// Call this whenever the selection changes, or needs to be re-laid out.
156        #[unsafe(method(setNeedsSelectionUpdate))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn setNeedsSelectionUpdate(&self);
159
160        #[unsafe(method(init))]
161        #[unsafe(method_family = init)]
162        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
163
164        #[unsafe(method(new))]
165        #[unsafe(method_family = new)]
166        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
167    );
168}