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        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
44extern_conformance!(
45    unsafe impl NSObjectProtocol for UITextSelectionDisplayInteraction {}
46);
47
48#[cfg(feature = "UIInteraction")]
49extern_conformance!(
50    unsafe impl UIInteraction for UITextSelectionDisplayInteraction {}
51);
52
53impl UITextSelectionDisplayInteraction {
54    extern_methods!(
55        /// Controls both the hidden sate of contained selection views as well as interactions that follow.
56        #[unsafe(method(isActivated))]
57        #[unsafe(method_family = none)]
58        pub fn isActivated(&self) -> bool;
59
60        /// Setter for [`isActivated`][Self::isActivated].
61        #[unsafe(method(setActivated:))]
62        #[unsafe(method_family = none)]
63        pub fn setActivated(&self, activated: bool);
64
65        #[cfg(all(feature = "UITextInput", feature = "UITextInputTraits"))]
66        /// The object the selection is being managed for.
67        #[unsafe(method(textInput))]
68        #[unsafe(method_family = none)]
69        pub fn textInput(&self) -> Option<Retained<ProtocolObject<dyn UITextInput>>>;
70
71        /// See
72        /// `UITextSelectionDisplayInteractionDelegate.`
73        #[unsafe(method(delegate))]
74        #[unsafe(method_family = none)]
75        pub fn delegate(
76            &self,
77        ) -> Option<Retained<ProtocolObject<dyn UITextSelectionDisplayInteractionDelegate>>>;
78
79        #[cfg(all(
80            feature = "UIResponder",
81            feature = "UITextCursorView",
82            feature = "UIView"
83        ))]
84        /// The cursor view (also known as "caret" view). Shown when the selection is not ranged.
85        #[unsafe(method(cursorView))]
86        #[unsafe(method_family = none)]
87        pub fn cursorView(&self) -> Retained<UIView>;
88
89        #[cfg(all(
90            feature = "UIResponder",
91            feature = "UITextCursorView",
92            feature = "UIView"
93        ))]
94        /// Setter for [`cursorView`][Self::cursorView].
95        ///
96        /// # Safety
97        ///
98        /// `cursor_view` must implement UITextCursorView.
99        #[unsafe(method(setCursorView:))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn setCursorView(&self, cursor_view: &UIView);
102
103        #[cfg(all(
104            feature = "UIResponder",
105            feature = "UITextSelectionHighlightView",
106            feature = "UIView"
107        ))]
108        /// The highlight view. This is the blue/tinted highlight drawn behind the rendered text.
109        #[unsafe(method(highlightView))]
110        #[unsafe(method_family = none)]
111        pub fn highlightView(&self) -> Retained<UIView>;
112
113        #[cfg(all(
114            feature = "UIResponder",
115            feature = "UITextSelectionHighlightView",
116            feature = "UIView"
117        ))]
118        /// Setter for [`highlightView`][Self::highlightView].
119        ///
120        /// # Safety
121        ///
122        /// `highlight_view` must implement UITextSelectionHighlightView.
123        #[unsafe(method(setHighlightView:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setHighlightView(&self, highlight_view: &UIView);
126
127        #[cfg(all(
128            feature = "UIResponder",
129            feature = "UITextSelectionHandleView",
130            feature = "UIView"
131        ))]
132        /// The selection handles, shown adjacent to the highlight view's
133        /// `selectionRects`when the selection is ranged.
134        ///
135        /// 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,
136        /// and another to be used as the trailing handle.
137        #[unsafe(method(handleViews))]
138        #[unsafe(method_family = none)]
139        pub fn handleViews(&self) -> Retained<NSArray<UIView>>;
140
141        #[cfg(all(
142            feature = "UIResponder",
143            feature = "UITextSelectionHandleView",
144            feature = "UIView"
145        ))]
146        /// Setter for [`handleViews`][Self::handleViews].
147        ///
148        /// # Safety
149        ///
150        /// `handle_views` generic must implement UITextSelectionHandleView.
151        #[unsafe(method(setHandleViews:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setHandleViews(&self, handle_views: &NSArray<UIView>);
154
155        #[cfg(all(feature = "UITextInput", feature = "UITextInputTraits"))]
156        /// Creates a UITextSelectionDisplayInteractionDelegate for a given object that implements the UITextInput protocol.
157        /// `textInput` may be the same as the view this interaction is installed onto.
158        #[unsafe(method(initWithTextInput:delegate:))]
159        #[unsafe(method_family = init)]
160        pub fn initWithTextInput_delegate(
161            this: Allocated<Self>,
162            text_input: &ProtocolObject<dyn UITextInput>,
163            delegate: &ProtocolObject<dyn UITextSelectionDisplayInteractionDelegate>,
164        ) -> Retained<Self>;
165
166        /// Loads the selection from `-[UITextInput selectedTextRange]` and applies the selection to all managed subviews.
167        #[unsafe(method(layoutManagedSubviews))]
168        #[unsafe(method_family = none)]
169        pub fn layoutManagedSubviews(&self);
170
171        /// Call this whenever the selection changes, or needs to be re-laid out.
172        #[unsafe(method(setNeedsSelectionUpdate))]
173        #[unsafe(method_family = none)]
174        pub fn setNeedsSelectionUpdate(&self);
175
176        #[unsafe(method(init))]
177        #[unsafe(method_family = init)]
178        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
179
180        #[unsafe(method(new))]
181        #[unsafe(method_family = new)]
182        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
183    );
184}