objc2_ui_kit/generated/
UITextInteraction.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
12/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinteractionmode?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UITextInteractionMode(pub NSInteger);
17impl UITextInteractionMode {
18    #[doc(alias = "UITextInteractionModeEditable")]
19    pub const Editable: Self = Self(0);
20    #[doc(alias = "UITextInteractionModeNonEditable")]
21    pub const NonEditable: Self = Self(1);
22}
23
24unsafe impl Encode for UITextInteractionMode {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for UITextInteractionMode {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_protocol!(
33    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinteractiondelegate?language=objc)
34    pub unsafe trait UITextInteractionDelegate: NSObjectProtocol + MainThreadOnly {
35        #[cfg(feature = "objc2-core-foundation")]
36        #[optional]
37        #[unsafe(method(interactionShouldBegin:atPoint:))]
38        #[unsafe(method_family = none)]
39        fn interactionShouldBegin_atPoint(
40            &self,
41            interaction: &UITextInteraction,
42            point: CGPoint,
43        ) -> bool;
44
45        #[optional]
46        #[unsafe(method(interactionWillBegin:))]
47        #[unsafe(method_family = none)]
48        fn interactionWillBegin(&self, interaction: &UITextInteraction);
49
50        #[optional]
51        #[unsafe(method(interactionDidEnd:))]
52        #[unsafe(method_family = none)]
53        fn interactionDidEnd(&self, interaction: &UITextInteraction);
54    }
55);
56
57extern_class!(
58    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextinteraction?language=objc)
59    #[unsafe(super(NSObject))]
60    #[thread_kind = MainThreadOnly]
61    #[derive(Debug, PartialEq, Eq, Hash)]
62    pub struct UITextInteraction;
63);
64
65extern_conformance!(
66    unsafe impl NSObjectProtocol for UITextInteraction {}
67);
68
69#[cfg(feature = "UIInteraction")]
70extern_conformance!(
71    unsafe impl UIInteraction for UITextInteraction {}
72);
73
74impl UITextInteraction {
75    extern_methods!(
76        #[unsafe(method(delegate))]
77        #[unsafe(method_family = none)]
78        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UITextInteractionDelegate>>>;
79
80        /// Setter for [`delegate`][Self::delegate].
81        ///
82        /// This is a [weak property][objc2::topics::weak_property].
83        #[unsafe(method(setDelegate:))]
84        #[unsafe(method_family = none)]
85        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UITextInteractionDelegate>>);
86
87        #[cfg(all(
88            feature = "UIResponder",
89            feature = "UITextInput",
90            feature = "UITextInputTraits"
91        ))]
92        #[unsafe(method(textInput))]
93        #[unsafe(method_family = none)]
94        pub fn textInput(&self) -> Option<Retained<UIResponder>>;
95
96        #[cfg(all(
97            feature = "UIResponder",
98            feature = "UITextInput",
99            feature = "UITextInputTraits"
100        ))]
101        /// Setter for [`textInput`][Self::textInput].
102        ///
103        /// This is a [weak property][objc2::topics::weak_property].
104        ///
105        /// # Safety
106        ///
107        /// `text_input` must implement UITextInput.
108        #[unsafe(method(setTextInput:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn setTextInput(&self, text_input: Option<&UIResponder>);
111
112        #[unsafe(method(textInteractionMode))]
113        #[unsafe(method_family = none)]
114        pub fn textInteractionMode(&self) -> UITextInteractionMode;
115
116        #[cfg(feature = "UIGestureRecognizer")]
117        #[unsafe(method(gesturesForFailureRequirements))]
118        #[unsafe(method_family = none)]
119        pub fn gesturesForFailureRequirements(&self) -> Retained<NSArray<UIGestureRecognizer>>;
120
121        #[unsafe(method(textInteractionForMode:))]
122        #[unsafe(method_family = none)]
123        pub fn textInteractionForMode(
124            mode: UITextInteractionMode,
125            mtm: MainThreadMarker,
126        ) -> Retained<Self>;
127    );
128}
129
130/// Methods declared on superclass `NSObject`.
131impl UITextInteraction {
132    extern_methods!(
133        #[unsafe(method(init))]
134        #[unsafe(method_family = init)]
135        pub fn init(this: Allocated<Self>) -> Retained<Self>;
136
137        #[unsafe(method(new))]
138        #[unsafe(method_family = new)]
139        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
140    );
141}