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
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 unsafe fn isActivated(&self) -> bool;
59
60        /// Setter for [`isActivated`][Self::isActivated].
61        #[unsafe(method(setActivated:))]
62        #[unsafe(method_family = none)]
63        pub unsafe 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 unsafe fn textInput(&self) -> Option<Retained<ProtocolObject<dyn UITextInput>>>;
70
71        /// See
72        /// `UITextSelectionDisplayInteractionDelegate.`
73        #[unsafe(method(delegate))]
74        #[unsafe(method_family = none)]
75        pub unsafe 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 unsafe 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        #[unsafe(method(setCursorView:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn setCursorView(&self, cursor_view: &UIView);
98
99        #[cfg(all(
100            feature = "UIResponder",
101            feature = "UITextSelectionHighlightView",
102            feature = "UIView"
103        ))]
104        /// The highlight view. This is the blue/tinted highlight drawn behind the rendered text.
105        #[unsafe(method(highlightView))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn highlightView(&self) -> Retained<UIView>;
108
109        #[cfg(all(
110            feature = "UIResponder",
111            feature = "UITextSelectionHighlightView",
112            feature = "UIView"
113        ))]
114        /// Setter for [`highlightView`][Self::highlightView].
115        #[unsafe(method(setHighlightView:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn setHighlightView(&self, highlight_view: &UIView);
118
119        #[cfg(all(
120            feature = "UIResponder",
121            feature = "UITextSelectionHandleView",
122            feature = "UIView"
123        ))]
124        /// The selection handles, shown adjacent to the highlight view's
125        /// `selectionRects`when the selection is ranged.
126        ///
127        /// 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,
128        /// and another to be used as the trailing handle.
129        #[unsafe(method(handleViews))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn handleViews(&self) -> Retained<NSArray<UIView>>;
132
133        #[cfg(all(
134            feature = "UIResponder",
135            feature = "UITextSelectionHandleView",
136            feature = "UIView"
137        ))]
138        /// Setter for [`handleViews`][Self::handleViews].
139        #[unsafe(method(setHandleViews:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn setHandleViews(&self, handle_views: &NSArray<UIView>);
142
143        #[cfg(all(feature = "UITextInput", feature = "UITextInputTraits"))]
144        /// Creates a UITextSelectionDisplayInteractionDelegate for a given object that implements the UITextInput protocol.
145        /// `textInput` may be the same as the view this interaction is installed onto.
146        #[unsafe(method(initWithTextInput:delegate:))]
147        #[unsafe(method_family = init)]
148        pub unsafe fn initWithTextInput_delegate(
149            this: Allocated<Self>,
150            text_input: &ProtocolObject<dyn UITextInput>,
151            delegate: &ProtocolObject<dyn UITextSelectionDisplayInteractionDelegate>,
152        ) -> Retained<Self>;
153
154        /// Loads the selection from `-[UITextInput selectedTextRange]` and applies the selection to all managed subviews.
155        #[unsafe(method(layoutManagedSubviews))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn layoutManagedSubviews(&self);
158
159        /// Call this whenever the selection changes, or needs to be re-laid out.
160        #[unsafe(method(setNeedsSelectionUpdate))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setNeedsSelectionUpdate(&self);
163
164        #[unsafe(method(init))]
165        #[unsafe(method_family = init)]
166        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
167
168        #[unsafe(method(new))]
169        #[unsafe(method_family = new)]
170        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
171    );
172}