objc2_ui_kit/generated/
UIFindInteraction.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/uifindinteractiondelegate?language=objc)
12    pub unsafe trait UIFindInteractionDelegate: NSObjectProtocol + MainThreadOnly {
13        #[cfg(all(feature = "UIFindSession", feature = "UIResponder", feature = "UIView"))]
14        /// Called when a find session is requested to begin by the user. Return an instance of a UIFindSession implementation to allow the
15        /// find session to begin, otherwise return nil to prevent the system find panel from appearing.
16        #[unsafe(method(findInteraction:sessionForView:))]
17        #[unsafe(method_family = none)]
18        fn findInteraction_sessionForView(
19            &self,
20            interaction: &UIFindInteraction,
21            view: &UIView,
22        ) -> Option<Retained<UIFindSession>>;
23
24        #[cfg(feature = "UIFindSession")]
25        /// Called when the search operation begins (and the system search UI appears).
26        /// This would be a good time to decorate your view to indicate that a search operation is about to occur.
27        /// System text elements will apply a dimming view around all non-highlighted search results, for instance.
28        #[optional]
29        #[unsafe(method(findInteraction:didBeginFindSession:))]
30        #[unsafe(method_family = none)]
31        fn findInteraction_didBeginFindSession(
32            &self,
33            interaction: &UIFindInteraction,
34            session: &UIFindSession,
35        );
36
37        #[cfg(feature = "UIFindSession")]
38        /// Called when the current search session has changed or ended. This would be a good time to remove all
39        /// decorations applied to found search results, and any decorations added when the search operation began
40        /// (such as a dimming view).
41        #[optional]
42        #[unsafe(method(findInteraction:didEndFindSession:))]
43        #[unsafe(method_family = none)]
44        fn findInteraction_didEndFindSession(
45            &self,
46            interaction: &UIFindInteraction,
47            session: &UIFindSession,
48        );
49    }
50);
51
52extern_class!(
53    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uifindinteraction?language=objc)
54    #[unsafe(super(NSObject))]
55    #[thread_kind = MainThreadOnly]
56    #[derive(Debug, PartialEq, Eq, Hash)]
57    pub struct UIFindInteraction;
58);
59
60extern_conformance!(
61    unsafe impl NSObjectProtocol for UIFindInteraction {}
62);
63
64#[cfg(feature = "UIInteraction")]
65extern_conformance!(
66    unsafe impl UIInteraction for UIFindInteraction {}
67);
68
69impl UIFindInteraction {
70    extern_methods!(
71        /// Returns YES if the find navigator panel is currently visible.
72        #[unsafe(method(isFindNavigatorVisible))]
73        #[unsafe(method_family = none)]
74        pub fn isFindNavigatorVisible(&self) -> bool;
75
76        #[cfg(feature = "UIFindSession")]
77        /// If there's a currently active find session (implying isFindNavigatorVisible is true), returns the active find session.
78        #[unsafe(method(activeFindSession))]
79        #[unsafe(method_family = none)]
80        pub fn activeFindSession(&self) -> Option<Retained<UIFindSession>>;
81
82        /// Assign this property to pre-populate the system find panel's search text field with a search query.
83        #[unsafe(method(searchText))]
84        #[unsafe(method_family = none)]
85        pub fn searchText(&self) -> Option<Retained<NSString>>;
86
87        /// Setter for [`searchText`][Self::searchText].
88        ///
89        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
90        #[unsafe(method(setSearchText:))]
91        #[unsafe(method_family = none)]
92        pub fn setSearchText(&self, search_text: Option<&NSString>);
93
94        /// If replacement is supported, assign this property to pre-populate the system find panel's replace text field with a replacement string.
95        #[unsafe(method(replacementText))]
96        #[unsafe(method_family = none)]
97        pub fn replacementText(&self) -> Option<Retained<NSString>>;
98
99        /// Setter for [`replacementText`][Self::replacementText].
100        ///
101        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
102        #[unsafe(method(setReplacementText:))]
103        #[unsafe(method_family = none)]
104        pub fn setReplacementText(&self, replacement_text: Option<&NSString>);
105
106        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
107        /// This provider is consulted when the search options menu is being populated. A default set of search options is provided, representing the options
108        /// available in
109        /// `UITextSearchOptions,`which can be either modified, augmented, or omitted.
110        ///
111        /// # Safety
112        ///
113        /// The returned block's argument must be a valid pointer.
114        #[unsafe(method(optionsMenuProvider))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn optionsMenuProvider(
117            &self,
118        ) -> *mut block2::DynBlock<dyn Fn(NonNull<NSArray<UIMenuElement>>) -> *mut UIMenu>;
119
120        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
121        /// Setter for [`optionsMenuProvider`][Self::optionsMenuProvider].
122        ///
123        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
124        ///
125        /// # Safety
126        ///
127        /// `options_menu_provider` block's return must be a valid pointer or null.
128        #[unsafe(method(setOptionsMenuProvider:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setOptionsMenuProvider(
131            &self,
132            options_menu_provider: Option<
133                &block2::DynBlock<dyn Fn(NonNull<NSArray<UIMenuElement>>) -> *mut UIMenu>,
134            >,
135        );
136
137        /// See UIFindInteractionDelegate above.
138        #[unsafe(method(delegate))]
139        #[unsafe(method_family = none)]
140        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UIFindInteractionDelegate>>>;
141
142        /// Creates a find interaction object with the specified delegate.
143        #[unsafe(method(initWithSessionDelegate:))]
144        #[unsafe(method_family = init)]
145        pub fn initWithSessionDelegate(
146            this: Allocated<Self>,
147            session_delegate: &ProtocolObject<dyn UIFindInteractionDelegate>,
148        ) -> Retained<Self>;
149
150        /// Shows the find navigator panel, if not already visible.
151        ///
152        ///
153        /// Parameter `replaceVisible`: If the delegate supports text replacement, will make the replace text field
154        /// visible on first appearance.
155        #[unsafe(method(presentFindNavigatorShowingReplace:))]
156        #[unsafe(method_family = none)]
157        pub fn presentFindNavigatorShowingReplace(&self, showing_replace: bool);
158
159        /// Dismisses the find navigator panel.
160        #[unsafe(method(dismissFindNavigator))]
161        #[unsafe(method_family = none)]
162        pub fn dismissFindNavigator(&self);
163
164        /// Jump to the next found result in the document, relative to the currently highlighted result.
165        #[unsafe(method(findNext))]
166        #[unsafe(method_family = none)]
167        pub fn findNext(&self);
168
169        /// Jump to the previous found result in the document, relative to the currently highlighted result.
170        #[unsafe(method(findPrevious))]
171        #[unsafe(method_family = none)]
172        pub fn findPrevious(&self);
173
174        /// Calling this triggers an update of the UI to reflect changes to the currently shown result count or result index, as defined by UIFindSession.
175        #[unsafe(method(updateResultCount))]
176        #[unsafe(method_family = none)]
177        pub fn updateResultCount(&self);
178
179        #[unsafe(method(new))]
180        #[unsafe(method_family = new)]
181        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
182
183        #[unsafe(method(init))]
184        #[unsafe(method_family = init)]
185        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
186    );
187}