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"))]
46extern_conformance!(
47 unsafe impl CALayerDelegate for UISearchTextField {}
48);
49
50#[cfg(all(
51 feature = "UIControl",
52 feature = "UIResponder",
53 feature = "UITextField",
54 feature = "UIView"
55))]
56extern_conformance!(
57 unsafe impl NSCoding for UISearchTextField {}
58);
59
60#[cfg(all(
61 feature = "UIControl",
62 feature = "UIResponder",
63 feature = "UITextField",
64 feature = "UIView"
65))]
66extern_conformance!(
67 unsafe impl NSObjectProtocol for UISearchTextField {}
68);
69
70#[cfg(all(
71 feature = "UIAppearance",
72 feature = "UIControl",
73 feature = "UIResponder",
74 feature = "UITextField",
75 feature = "UIView"
76))]
77extern_conformance!(
78 unsafe impl UIAppearance for UISearchTextField {}
79);
80
81#[cfg(all(
82 feature = "UIAppearance",
83 feature = "UIControl",
84 feature = "UIResponder",
85 feature = "UITextField",
86 feature = "UIView"
87))]
88extern_conformance!(
89 unsafe impl UIAppearanceContainer for UISearchTextField {}
90);
91
92#[cfg(all(
93 feature = "UIContentSizeCategoryAdjusting",
94 feature = "UIControl",
95 feature = "UIResponder",
96 feature = "UITextField",
97 feature = "UIView"
98))]
99extern_conformance!(
100 unsafe impl UIContentSizeCategoryAdjusting for UISearchTextField {}
101);
102
103#[cfg(all(
104 feature = "UIControl",
105 feature = "UIResponder",
106 feature = "UITextField",
107 feature = "UIView"
108))]
109extern_conformance!(
110 unsafe impl UICoordinateSpace for UISearchTextField {}
111);
112
113#[cfg(all(
114 feature = "UIControl",
115 feature = "UIDynamicBehavior",
116 feature = "UIResponder",
117 feature = "UITextField",
118 feature = "UIView"
119))]
120extern_conformance!(
121 unsafe impl UIDynamicItem for UISearchTextField {}
122);
123
124#[cfg(all(
125 feature = "UIControl",
126 feature = "UIFocus",
127 feature = "UIResponder",
128 feature = "UITextField",
129 feature = "UIView"
130))]
131extern_conformance!(
132 unsafe impl UIFocusEnvironment for UISearchTextField {}
133);
134
135#[cfg(all(
136 feature = "UIControl",
137 feature = "UIFocus",
138 feature = "UIResponder",
139 feature = "UITextField",
140 feature = "UIView"
141))]
142extern_conformance!(
143 unsafe impl UIFocusItem for UISearchTextField {}
144);
145
146#[cfg(all(
147 feature = "UIControl",
148 feature = "UIFocus",
149 feature = "UIResponder",
150 feature = "UITextField",
151 feature = "UIView"
152))]
153extern_conformance!(
154 unsafe impl UIFocusItemContainer for UISearchTextField {}
155);
156
157#[cfg(all(
158 feature = "UIControl",
159 feature = "UIResponder",
160 feature = "UITextField",
161 feature = "UITextInput",
162 feature = "UITextInputTraits",
163 feature = "UIView"
164))]
165extern_conformance!(
166 unsafe impl UIKeyInput for UISearchTextField {}
167);
168
169#[cfg(all(
170 feature = "UIControl",
171 feature = "UILetterformAwareAdjusting",
172 feature = "UIResponder",
173 feature = "UITextField",
174 feature = "UIView"
175))]
176extern_conformance!(
177 unsafe impl UILetterformAwareAdjusting for UISearchTextField {}
178);
179
180#[cfg(all(
181 feature = "UIControl",
182 feature = "UIResponder",
183 feature = "UITextField",
184 feature = "UIView"
185))]
186extern_conformance!(
187 unsafe impl UIResponderStandardEditActions for UISearchTextField {}
188);
189
190#[cfg(all(
191 feature = "UIControl",
192 feature = "UIResponder",
193 feature = "UITextField",
194 feature = "UITextInput",
195 feature = "UITextInputTraits",
196 feature = "UIView"
197))]
198extern_conformance!(
199 unsafe impl UITextInput for UISearchTextField {}
200);
201
202#[cfg(all(
203 feature = "UIControl",
204 feature = "UIResponder",
205 feature = "UITextField",
206 feature = "UITextInputTraits",
207 feature = "UIView"
208))]
209extern_conformance!(
210 unsafe impl UITextInputTraits for UISearchTextField {}
211);
212
213#[cfg(all(
214 feature = "UIControl",
215 feature = "UIResponder",
216 feature = "UITextField",
217 feature = "UITraitCollection",
218 feature = "UIView"
219))]
220extern_conformance!(
221 unsafe impl UITraitEnvironment for UISearchTextField {}
222);
223
224#[cfg(all(
225 feature = "UIControl",
226 feature = "UIResponder",
227 feature = "UITextField",
228 feature = "UIView"
229))]
230impl UISearchTextField {
231 extern_methods!(
232 #[unsafe(method(tokens))]
234 #[unsafe(method_family = none)]
235 pub fn tokens(&self) -> Retained<NSArray<UISearchToken>>;
236
237 #[unsafe(method(setTokens:))]
241 #[unsafe(method_family = none)]
242 pub fn setTokens(&self, tokens: &NSArray<UISearchToken>);
243
244 #[unsafe(method(insertToken:atIndex:))]
245 #[unsafe(method_family = none)]
246 pub fn insertToken_atIndex(&self, token: &UISearchToken, token_index: NSInteger);
247
248 #[unsafe(method(removeTokenAtIndex:))]
249 #[unsafe(method_family = none)]
250 pub fn removeTokenAtIndex(&self, token_index: NSInteger);
251
252 #[cfg(feature = "UITextInput")]
253 #[unsafe(method(positionOfTokenAtIndex:))]
255 #[unsafe(method_family = none)]
256 pub fn positionOfTokenAtIndex(&self, token_index: NSInteger) -> Retained<UITextPosition>;
257
258 #[cfg(feature = "UITextInput")]
259 #[unsafe(method(tokensInRange:))]
263 #[unsafe(method_family = none)]
264 pub fn tokensInRange(&self, text_range: &UITextRange) -> Retained<NSArray<UISearchToken>>;
265
266 #[cfg(feature = "UITextInput")]
267 #[unsafe(method(textualRange))]
274 #[unsafe(method_family = none)]
275 pub fn textualRange(&self) -> Retained<UITextRange>;
276
277 #[cfg(feature = "UITextInput")]
278 #[unsafe(method(replaceTextualPortionOfRange:withToken:atIndex:))]
285 #[unsafe(method_family = none)]
286 pub fn replaceTextualPortionOfRange_withToken_atIndex(
287 &self,
288 text_range: &UITextRange,
289 token: &UISearchToken,
290 token_index: NSUInteger,
291 );
292
293 #[cfg(feature = "UIColor")]
294 #[unsafe(method(tokenBackgroundColor))]
296 #[unsafe(method_family = none)]
297 pub fn tokenBackgroundColor(&self) -> Option<Retained<UIColor>>;
298
299 #[cfg(feature = "UIColor")]
300 #[unsafe(method(setTokenBackgroundColor:))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn setTokenBackgroundColor(&self, token_background_color: Option<&UIColor>);
308
309 #[unsafe(method(allowsDeletingTokens))]
313 #[unsafe(method_family = none)]
314 pub fn allowsDeletingTokens(&self) -> bool;
315
316 #[unsafe(method(setAllowsDeletingTokens:))]
318 #[unsafe(method_family = none)]
319 pub fn setAllowsDeletingTokens(&self, allows_deleting_tokens: bool);
320
321 #[unsafe(method(allowsCopyingTokens))]
325 #[unsafe(method_family = none)]
326 pub fn allowsCopyingTokens(&self) -> bool;
327
328 #[unsafe(method(setAllowsCopyingTokens:))]
330 #[unsafe(method_family = none)]
331 pub fn setAllowsCopyingTokens(&self, allows_copying_tokens: bool);
332
333 #[cfg(feature = "UISearchSuggestion")]
334 #[unsafe(method(searchSuggestions))]
341 #[unsafe(method_family = none)]
342 pub fn searchSuggestions(
343 &self,
344 ) -> Option<Retained<NSArray<ProtocolObject<dyn UISearchSuggestion>>>>;
345
346 #[cfg(feature = "UISearchSuggestion")]
347 #[unsafe(method(setSearchSuggestions:))]
351 #[unsafe(method_family = none)]
352 pub fn setSearchSuggestions(
353 &self,
354 search_suggestions: Option<&NSArray<ProtocolObject<dyn UISearchSuggestion>>>,
355 );
356 );
357}
358
359#[cfg(all(
361 feature = "UIControl",
362 feature = "UIResponder",
363 feature = "UITextField",
364 feature = "UIView"
365))]
366impl UISearchTextField {
367 extern_methods!(
368 #[cfg(feature = "objc2-core-foundation")]
369 #[unsafe(method(initWithFrame:))]
370 #[unsafe(method_family = init)]
371 pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
372
373 #[unsafe(method(initWithCoder:))]
377 #[unsafe(method_family = init)]
378 pub unsafe fn initWithCoder(
379 this: Allocated<Self>,
380 coder: &NSCoder,
381 ) -> Option<Retained<Self>>;
382
383 #[cfg(all(
384 feature = "UIAction",
385 feature = "UIMenuElement",
386 feature = "objc2-core-foundation"
387 ))]
388 #[unsafe(method(initWithFrame:primaryAction:))]
390 #[unsafe(method_family = init)]
391 pub fn initWithFrame_primaryAction(
392 this: Allocated<Self>,
393 frame: CGRect,
394 primary_action: Option<&UIAction>,
395 ) -> Retained<Self>;
396 );
397}
398
399#[cfg(all(
401 feature = "UIControl",
402 feature = "UIResponder",
403 feature = "UITextField",
404 feature = "UIView"
405))]
406impl UISearchTextField {
407 extern_methods!(
408 #[unsafe(method(init))]
409 #[unsafe(method_family = init)]
410 pub fn init(this: Allocated<Self>) -> Retained<Self>;
411 );
412}
413
414#[cfg(all(
416 feature = "UIControl",
417 feature = "UIResponder",
418 feature = "UITextField",
419 feature = "UIView"
420))]
421impl UISearchTextField {
422 extern_methods!(
423 #[unsafe(method(new))]
424 #[unsafe(method_family = new)]
425 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
426 );
427}
428
429extern_class!(
430 #[unsafe(super(NSObject))]
434 #[thread_kind = MainThreadOnly]
435 #[derive(Debug, PartialEq, Eq, Hash)]
436 pub struct UISearchToken;
437);
438
439extern_conformance!(
440 unsafe impl NSObjectProtocol for UISearchToken {}
441);
442
443impl UISearchToken {
444 extern_methods!(
445 #[unsafe(method(init))]
446 #[unsafe(method_family = init)]
447 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
448
449 #[unsafe(method(new))]
450 #[unsafe(method_family = new)]
451 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
452
453 #[cfg(feature = "UIImage")]
454 #[unsafe(method(tokenWithIcon:text:))]
455 #[unsafe(method_family = none)]
456 pub fn tokenWithIcon_text(
457 icon: Option<&UIImage>,
458 text: &NSString,
459 mtm: MainThreadMarker,
460 ) -> Retained<UISearchToken>;
461
462 #[unsafe(method(representedObject))]
469 #[unsafe(method_family = none)]
470 pub fn representedObject(&self) -> Option<Retained<AnyObject>>;
471
472 #[unsafe(method(setRepresentedObject:))]
478 #[unsafe(method_family = none)]
479 pub unsafe fn setRepresentedObject(&self, represented_object: Option<&AnyObject>);
480 );
481}
482
483extern_protocol!(
484 #[cfg(feature = "UITextField")]
486 pub unsafe trait UISearchTextFieldDelegate:
487 UITextFieldDelegate + MainThreadOnly
488 {
489 #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
490 #[optional]
496 #[unsafe(method(searchTextField:itemProviderForCopyingToken:))]
497 #[unsafe(method_family = none)]
498 fn searchTextField_itemProviderForCopyingToken(
499 &self,
500 search_text_field: &UISearchTextField,
501 token: &UISearchToken,
502 ) -> Retained<NSItemProvider>;
503
504 #[cfg(all(
505 feature = "UIControl",
506 feature = "UIResponder",
507 feature = "UISearchSuggestion",
508 feature = "UIView"
509 ))]
510 #[optional]
512 #[unsafe(method(searchTextField:didSelectSuggestion:))]
513 #[unsafe(method_family = none)]
514 fn searchTextField_didSelectSuggestion(
515 &self,
516 search_text_field: &UISearchTextField,
517 suggestion: &ProtocolObject<dyn UISearchSuggestion>,
518 );
519 }
520);
521
522extern_protocol!(
523 #[cfg(feature = "UITextPasteDelegate")]
529 pub unsafe trait UISearchTextFieldPasteItem: UITextPasteItem + MainThreadOnly {
530 #[unsafe(method(setSearchTokenResult:))]
532 #[unsafe(method_family = none)]
533 fn setSearchTokenResult(&self, token: &UISearchToken);
534 }
535);