1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15extern_class!(
16 #[unsafe(super(UITextField, UIControl, UIView, UIResponder, NSObject))]
27 #[thread_kind = MainThreadOnly]
28 #[derive(Debug, PartialEq, Eq, Hash)]
29 #[cfg(all(
30 feature = "UIControl",
31 feature = "UIResponder",
32 feature = "UITextField",
33 feature = "UIView"
34 ))]
35 pub struct UISearchTextField;
36);
37
38#[cfg(all(
39 feature = "UIControl",
40 feature = "UIResponder",
41 feature = "UITextField",
42 feature = "UIView",
43 feature = "objc2-quartz-core"
44))]
45#[cfg(not(target_os = "watchos"))]
46unsafe impl CALayerDelegate for UISearchTextField {}
47
48#[cfg(all(
49 feature = "UIControl",
50 feature = "UIResponder",
51 feature = "UITextField",
52 feature = "UIView"
53))]
54unsafe impl NSCoding for UISearchTextField {}
55
56#[cfg(all(
57 feature = "UIControl",
58 feature = "UIResponder",
59 feature = "UITextField",
60 feature = "UIView"
61))]
62unsafe impl NSObjectProtocol for UISearchTextField {}
63
64#[cfg(all(
65 feature = "UIAppearance",
66 feature = "UIControl",
67 feature = "UIResponder",
68 feature = "UITextField",
69 feature = "UIView"
70))]
71unsafe impl UIAppearance for UISearchTextField {}
72
73#[cfg(all(
74 feature = "UIAppearance",
75 feature = "UIControl",
76 feature = "UIResponder",
77 feature = "UITextField",
78 feature = "UIView"
79))]
80unsafe impl UIAppearanceContainer for UISearchTextField {}
81
82#[cfg(all(
83 feature = "UIContentSizeCategoryAdjusting",
84 feature = "UIControl",
85 feature = "UIResponder",
86 feature = "UITextField",
87 feature = "UIView"
88))]
89unsafe impl UIContentSizeCategoryAdjusting for UISearchTextField {}
90
91#[cfg(all(
92 feature = "UIControl",
93 feature = "UIResponder",
94 feature = "UITextField",
95 feature = "UIView"
96))]
97unsafe impl UICoordinateSpace for UISearchTextField {}
98
99#[cfg(all(
100 feature = "UIControl",
101 feature = "UIDynamicBehavior",
102 feature = "UIResponder",
103 feature = "UITextField",
104 feature = "UIView"
105))]
106unsafe impl UIDynamicItem for UISearchTextField {}
107
108#[cfg(all(
109 feature = "UIControl",
110 feature = "UIFocus",
111 feature = "UIResponder",
112 feature = "UITextField",
113 feature = "UIView"
114))]
115unsafe impl UIFocusEnvironment for UISearchTextField {}
116
117#[cfg(all(
118 feature = "UIControl",
119 feature = "UIFocus",
120 feature = "UIResponder",
121 feature = "UITextField",
122 feature = "UIView"
123))]
124unsafe impl UIFocusItem for UISearchTextField {}
125
126#[cfg(all(
127 feature = "UIControl",
128 feature = "UIFocus",
129 feature = "UIResponder",
130 feature = "UITextField",
131 feature = "UIView"
132))]
133unsafe impl UIFocusItemContainer for UISearchTextField {}
134
135#[cfg(all(
136 feature = "UIControl",
137 feature = "UIResponder",
138 feature = "UITextField",
139 feature = "UITextInput",
140 feature = "UITextInputTraits",
141 feature = "UIView"
142))]
143unsafe impl UIKeyInput for UISearchTextField {}
144
145#[cfg(all(
146 feature = "UIControl",
147 feature = "UILetterformAwareAdjusting",
148 feature = "UIResponder",
149 feature = "UITextField",
150 feature = "UIView"
151))]
152unsafe impl UILetterformAwareAdjusting for UISearchTextField {}
153
154#[cfg(all(
155 feature = "UIControl",
156 feature = "UIResponder",
157 feature = "UITextField",
158 feature = "UIView"
159))]
160unsafe impl UIResponderStandardEditActions for UISearchTextField {}
161
162#[cfg(all(
163 feature = "UIControl",
164 feature = "UIResponder",
165 feature = "UITextField",
166 feature = "UITextInput",
167 feature = "UITextInputTraits",
168 feature = "UIView"
169))]
170unsafe impl UITextInput for UISearchTextField {}
171
172#[cfg(all(
173 feature = "UIControl",
174 feature = "UIResponder",
175 feature = "UITextField",
176 feature = "UITextInputTraits",
177 feature = "UIView"
178))]
179unsafe impl UITextInputTraits for UISearchTextField {}
180
181#[cfg(all(
182 feature = "UIControl",
183 feature = "UIResponder",
184 feature = "UITextField",
185 feature = "UITraitCollection",
186 feature = "UIView"
187))]
188unsafe impl UITraitEnvironment for UISearchTextField {}
189
190#[cfg(all(
191 feature = "UIControl",
192 feature = "UIResponder",
193 feature = "UITextField",
194 feature = "UIView"
195))]
196impl UISearchTextField {
197 extern_methods!(
198 #[unsafe(method(tokens))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn tokens(&self) -> Retained<NSArray<UISearchToken>>;
202
203 #[unsafe(method(setTokens:))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn setTokens(&self, tokens: &NSArray<UISearchToken>);
207
208 #[unsafe(method(insertToken:atIndex:))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn insertToken_atIndex(&self, token: &UISearchToken, token_index: NSInteger);
211
212 #[unsafe(method(removeTokenAtIndex:))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn removeTokenAtIndex(&self, token_index: NSInteger);
215
216 #[cfg(feature = "UITextInput")]
217 #[unsafe(method(positionOfTokenAtIndex:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn positionOfTokenAtIndex(
221 &self,
222 token_index: NSInteger,
223 ) -> Retained<UITextPosition>;
224
225 #[cfg(feature = "UITextInput")]
226 #[unsafe(method(tokensInRange:))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn tokensInRange(
232 &self,
233 text_range: &UITextRange,
234 ) -> Retained<NSArray<UISearchToken>>;
235
236 #[cfg(feature = "UITextInput")]
237 #[unsafe(method(textualRange))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn textualRange(&self) -> Retained<UITextRange>;
246
247 #[cfg(feature = "UITextInput")]
248 #[unsafe(method(replaceTextualPortionOfRange:withToken:atIndex:))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn replaceTextualPortionOfRange_withToken_atIndex(
257 &self,
258 text_range: &UITextRange,
259 token: &UISearchToken,
260 token_index: NSUInteger,
261 );
262
263 #[cfg(feature = "UIColor")]
264 #[unsafe(method(tokenBackgroundColor))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn tokenBackgroundColor(&self) -> Option<Retained<UIColor>>;
268
269 #[cfg(feature = "UIColor")]
270 #[unsafe(method(setTokenBackgroundColor:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn setTokenBackgroundColor(&self, token_background_color: Option<&UIColor>);
274
275 #[unsafe(method(allowsDeletingTokens))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn allowsDeletingTokens(&self) -> bool;
281
282 #[unsafe(method(setAllowsDeletingTokens:))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn setAllowsDeletingTokens(&self, allows_deleting_tokens: bool);
286
287 #[unsafe(method(allowsCopyingTokens))]
291 #[unsafe(method_family = none)]
292 pub unsafe fn allowsCopyingTokens(&self) -> bool;
293
294 #[unsafe(method(setAllowsCopyingTokens:))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn setAllowsCopyingTokens(&self, allows_copying_tokens: bool);
298
299 #[cfg(feature = "UISearchSuggestion")]
300 #[unsafe(method(searchSuggestions))]
307 #[unsafe(method_family = none)]
308 pub unsafe fn searchSuggestions(
309 &self,
310 ) -> Option<Retained<NSArray<ProtocolObject<dyn UISearchSuggestion>>>>;
311
312 #[cfg(feature = "UISearchSuggestion")]
313 #[unsafe(method(setSearchSuggestions:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn setSearchSuggestions(
317 &self,
318 search_suggestions: Option<&NSArray<ProtocolObject<dyn UISearchSuggestion>>>,
319 );
320 );
321}
322
323#[cfg(all(
325 feature = "UIControl",
326 feature = "UIResponder",
327 feature = "UITextField",
328 feature = "UIView"
329))]
330impl UISearchTextField {
331 extern_methods!(
332 #[cfg(feature = "objc2-core-foundation")]
333 #[unsafe(method(initWithFrame:))]
334 #[unsafe(method_family = init)]
335 pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
336
337 #[unsafe(method(initWithCoder:))]
338 #[unsafe(method_family = init)]
339 pub unsafe fn initWithCoder(
340 this: Allocated<Self>,
341 coder: &NSCoder,
342 ) -> Option<Retained<Self>>;
343
344 #[cfg(all(
345 feature = "UIAction",
346 feature = "UIMenuElement",
347 feature = "objc2-core-foundation"
348 ))]
349 #[unsafe(method(initWithFrame:primaryAction:))]
351 #[unsafe(method_family = init)]
352 pub unsafe fn initWithFrame_primaryAction(
353 this: Allocated<Self>,
354 frame: CGRect,
355 primary_action: Option<&UIAction>,
356 ) -> Retained<Self>;
357 );
358}
359
360#[cfg(all(
362 feature = "UIControl",
363 feature = "UIResponder",
364 feature = "UITextField",
365 feature = "UIView"
366))]
367impl UISearchTextField {
368 extern_methods!(
369 #[unsafe(method(init))]
370 #[unsafe(method_family = init)]
371 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
372
373 #[unsafe(method(new))]
374 #[unsafe(method_family = new)]
375 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
376 );
377}
378
379extern_class!(
380 #[unsafe(super(NSObject))]
384 #[thread_kind = MainThreadOnly]
385 #[derive(Debug, PartialEq, Eq, Hash)]
386 pub struct UISearchToken;
387);
388
389unsafe impl NSObjectProtocol for UISearchToken {}
390
391impl UISearchToken {
392 extern_methods!(
393 #[unsafe(method(init))]
394 #[unsafe(method_family = init)]
395 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
396
397 #[unsafe(method(new))]
398 #[unsafe(method_family = new)]
399 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
400
401 #[cfg(feature = "UIImage")]
402 #[unsafe(method(tokenWithIcon:text:))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn tokenWithIcon_text(
405 icon: Option<&UIImage>,
406 text: &NSString,
407 mtm: MainThreadMarker,
408 ) -> Retained<UISearchToken>;
409
410 #[unsafe(method(representedObject))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn representedObject(&self) -> Option<Retained<AnyObject>>;
419
420 #[unsafe(method(setRepresentedObject:))]
422 #[unsafe(method_family = none)]
423 pub unsafe fn setRepresentedObject(&self, represented_object: Option<&AnyObject>);
424 );
425}
426
427extern_protocol!(
428 #[cfg(feature = "UITextField")]
430 pub unsafe trait UISearchTextFieldDelegate:
431 UITextFieldDelegate + MainThreadOnly
432 {
433 #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
434 #[optional]
440 #[unsafe(method(searchTextField:itemProviderForCopyingToken:))]
441 #[unsafe(method_family = none)]
442 unsafe fn searchTextField_itemProviderForCopyingToken(
443 &self,
444 search_text_field: &UISearchTextField,
445 token: &UISearchToken,
446 ) -> Retained<NSItemProvider>;
447
448 #[cfg(all(
449 feature = "UIControl",
450 feature = "UIResponder",
451 feature = "UISearchSuggestion",
452 feature = "UIView"
453 ))]
454 #[optional]
456 #[unsafe(method(searchTextField:didSelectSuggestion:))]
457 #[unsafe(method_family = none)]
458 unsafe fn searchTextField_didSelectSuggestion(
459 &self,
460 search_text_field: &UISearchTextField,
461 suggestion: &ProtocolObject<dyn UISearchSuggestion>,
462 );
463 }
464);
465
466extern_protocol!(
467 #[cfg(feature = "UITextPasteDelegate")]
473 pub unsafe trait UISearchTextFieldPasteItem: UITextPasteItem + MainThreadOnly {
474 #[unsafe(method(setSearchTokenResult:))]
476 #[unsafe(method_family = none)]
477 unsafe fn setSearchTokenResult(&self, token: &UISearchToken);
478 }
479);