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        unsafe 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        unsafe 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        unsafe 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
60unsafe impl NSObjectProtocol for UIFindInteraction {}
61
62#[cfg(feature = "UIInteraction")]
63unsafe impl UIInteraction for UIFindInteraction {}
64
65impl UIFindInteraction {
66    extern_methods!(
67        /// Returns YES if the find navigator panel is currently visible.
68        #[unsafe(method(isFindNavigatorVisible))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn isFindNavigatorVisible(&self) -> bool;
71
72        #[cfg(feature = "UIFindSession")]
73        /// If there's a currently active find session (implying isFindNavigatorVisible is true), returns the active find session.
74        #[unsafe(method(activeFindSession))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn activeFindSession(&self) -> Option<Retained<UIFindSession>>;
77
78        /// Assign this property to pre-populate the system find panel's search text field with a search query.
79        #[unsafe(method(searchText))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn searchText(&self) -> Option<Retained<NSString>>;
82
83        /// Setter for [`searchText`][Self::searchText].
84        #[unsafe(method(setSearchText:))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn setSearchText(&self, search_text: Option<&NSString>);
87
88        /// If replacement is supported, assign this property to pre-populate the system find panel's replace text field with a replacement string.
89        #[unsafe(method(replacementText))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn replacementText(&self) -> Option<Retained<NSString>>;
92
93        /// Setter for [`replacementText`][Self::replacementText].
94        #[unsafe(method(setReplacementText:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn setReplacementText(&self, replacement_text: Option<&NSString>);
97
98        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
99        /// This provider is consulted when the search options menu is being populated. A default set of search options is provided, representing the options
100        /// available in
101        /// `UITextSearchOptions,`which can be either modified, augmented, or omitted.
102        #[unsafe(method(optionsMenuProvider))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn optionsMenuProvider(
105            &self,
106        ) -> *mut block2::Block<dyn Fn(NonNull<NSArray<UIMenuElement>>) -> *mut UIMenu>;
107
108        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
109        /// Setter for [`optionsMenuProvider`][Self::optionsMenuProvider].
110        #[unsafe(method(setOptionsMenuProvider:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn setOptionsMenuProvider(
113            &self,
114            options_menu_provider: Option<
115                &block2::Block<dyn Fn(NonNull<NSArray<UIMenuElement>>) -> *mut UIMenu>,
116            >,
117        );
118
119        /// See UIFindInteractionDelegate above.
120        #[unsafe(method(delegate))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn delegate(
123            &self,
124        ) -> Option<Retained<ProtocolObject<dyn UIFindInteractionDelegate>>>;
125
126        /// Creates a find interaction object with the specified delegate.
127        #[unsafe(method(initWithSessionDelegate:))]
128        #[unsafe(method_family = init)]
129        pub unsafe fn initWithSessionDelegate(
130            this: Allocated<Self>,
131            session_delegate: &ProtocolObject<dyn UIFindInteractionDelegate>,
132        ) -> Retained<Self>;
133
134        /// Shows the find navigator panel, if not already visible.
135        ///
136        ///
137        /// Parameter `replaceVisible`: If the delegate supports text replacement, will make the replace text field
138        /// visible on first appearance.
139        #[unsafe(method(presentFindNavigatorShowingReplace:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn presentFindNavigatorShowingReplace(&self, showing_replace: bool);
142
143        /// Dismisses the find navigator panel.
144        #[unsafe(method(dismissFindNavigator))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn dismissFindNavigator(&self);
147
148        /// Jump to the next found result in the document, relative to the currently highlighted result.
149        #[unsafe(method(findNext))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn findNext(&self);
152
153        /// Jump to the previous found result in the document, relative to the currently highlighted result.
154        #[unsafe(method(findPrevious))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn findPrevious(&self);
157
158        /// Calling this triggers an update of the UI to reflect changes to the currently shown result count or result index, as defined by UIFindSession.
159        #[unsafe(method(updateResultCount))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn updateResultCount(&self);
162
163        #[unsafe(method(new))]
164        #[unsafe(method_family = new)]
165        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
166
167        #[unsafe(method(init))]
168        #[unsafe(method_family = init)]
169        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
170    );
171}