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 unsafe fn tokens(&self) -> Retained<NSArray<UISearchToken>>;
236
237 #[unsafe(method(setTokens:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn setTokens(&self, tokens: &NSArray<UISearchToken>);
241
242 #[unsafe(method(insertToken:atIndex:))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn insertToken_atIndex(&self, token: &UISearchToken, token_index: NSInteger);
245
246 #[unsafe(method(removeTokenAtIndex:))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn removeTokenAtIndex(&self, token_index: NSInteger);
249
250 #[cfg(feature = "UITextInput")]
251 #[unsafe(method(positionOfTokenAtIndex:))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn positionOfTokenAtIndex(
255 &self,
256 token_index: NSInteger,
257 ) -> Retained<UITextPosition>;
258
259 #[cfg(feature = "UITextInput")]
260 #[unsafe(method(tokensInRange:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn tokensInRange(
266 &self,
267 text_range: &UITextRange,
268 ) -> Retained<NSArray<UISearchToken>>;
269
270 #[cfg(feature = "UITextInput")]
271 #[unsafe(method(textualRange))]
278 #[unsafe(method_family = none)]
279 pub unsafe fn textualRange(&self) -> Retained<UITextRange>;
280
281 #[cfg(feature = "UITextInput")]
282 #[unsafe(method(replaceTextualPortionOfRange:withToken:atIndex:))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn replaceTextualPortionOfRange_withToken_atIndex(
291 &self,
292 text_range: &UITextRange,
293 token: &UISearchToken,
294 token_index: NSUInteger,
295 );
296
297 #[cfg(feature = "UIColor")]
298 #[unsafe(method(tokenBackgroundColor))]
300 #[unsafe(method_family = none)]
301 pub unsafe fn tokenBackgroundColor(&self) -> Option<Retained<UIColor>>;
302
303 #[cfg(feature = "UIColor")]
304 #[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 unsafe fn allowsDeletingTokens(&self) -> bool;
315
316 #[unsafe(method(setAllowsDeletingTokens:))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn setAllowsDeletingTokens(&self, allows_deleting_tokens: bool);
320
321 #[unsafe(method(allowsCopyingTokens))]
325 #[unsafe(method_family = none)]
326 pub unsafe fn allowsCopyingTokens(&self) -> bool;
327
328 #[unsafe(method(setAllowsCopyingTokens:))]
330 #[unsafe(method_family = none)]
331 pub unsafe fn setAllowsCopyingTokens(&self, allows_copying_tokens: bool);
332
333 #[cfg(feature = "UISearchSuggestion")]
334 #[unsafe(method(searchSuggestions))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn searchSuggestions(
343 &self,
344 ) -> Option<Retained<NSArray<ProtocolObject<dyn UISearchSuggestion>>>>;
345
346 #[cfg(feature = "UISearchSuggestion")]
347 #[unsafe(method(setSearchSuggestions:))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn setSearchSuggestions(
351 &self,
352 search_suggestions: Option<&NSArray<ProtocolObject<dyn UISearchSuggestion>>>,
353 );
354 );
355}
356
357#[cfg(all(
359 feature = "UIControl",
360 feature = "UIResponder",
361 feature = "UITextField",
362 feature = "UIView"
363))]
364impl UISearchTextField {
365 extern_methods!(
366 #[cfg(feature = "objc2-core-foundation")]
367 #[unsafe(method(initWithFrame:))]
368 #[unsafe(method_family = init)]
369 pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
370
371 #[unsafe(method(initWithCoder:))]
372 #[unsafe(method_family = init)]
373 pub unsafe fn initWithCoder(
374 this: Allocated<Self>,
375 coder: &NSCoder,
376 ) -> Option<Retained<Self>>;
377
378 #[cfg(all(
379 feature = "UIAction",
380 feature = "UIMenuElement",
381 feature = "objc2-core-foundation"
382 ))]
383 #[unsafe(method(initWithFrame:primaryAction:))]
385 #[unsafe(method_family = init)]
386 pub unsafe fn initWithFrame_primaryAction(
387 this: Allocated<Self>,
388 frame: CGRect,
389 primary_action: Option<&UIAction>,
390 ) -> Retained<Self>;
391 );
392}
393
394#[cfg(all(
396 feature = "UIControl",
397 feature = "UIResponder",
398 feature = "UITextField",
399 feature = "UIView"
400))]
401impl UISearchTextField {
402 extern_methods!(
403 #[unsafe(method(init))]
404 #[unsafe(method_family = init)]
405 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
406
407 #[unsafe(method(new))]
408 #[unsafe(method_family = new)]
409 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
410 );
411}
412
413extern_class!(
414 #[unsafe(super(NSObject))]
418 #[thread_kind = MainThreadOnly]
419 #[derive(Debug, PartialEq, Eq, Hash)]
420 pub struct UISearchToken;
421);
422
423extern_conformance!(
424 unsafe impl NSObjectProtocol for UISearchToken {}
425);
426
427impl UISearchToken {
428 extern_methods!(
429 #[unsafe(method(init))]
430 #[unsafe(method_family = init)]
431 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
432
433 #[unsafe(method(new))]
434 #[unsafe(method_family = new)]
435 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
436
437 #[cfg(feature = "UIImage")]
438 #[unsafe(method(tokenWithIcon:text:))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn tokenWithIcon_text(
441 icon: Option<&UIImage>,
442 text: &NSString,
443 mtm: MainThreadMarker,
444 ) -> Retained<UISearchToken>;
445
446 #[unsafe(method(representedObject))]
453 #[unsafe(method_family = none)]
454 pub unsafe fn representedObject(&self) -> Option<Retained<AnyObject>>;
455
456 #[unsafe(method(setRepresentedObject:))]
458 #[unsafe(method_family = none)]
459 pub unsafe fn setRepresentedObject(&self, represented_object: Option<&AnyObject>);
460 );
461}
462
463extern_protocol!(
464 #[cfg(feature = "UITextField")]
466 pub unsafe trait UISearchTextFieldDelegate:
467 UITextFieldDelegate + MainThreadOnly
468 {
469 #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
470 #[optional]
476 #[unsafe(method(searchTextField:itemProviderForCopyingToken:))]
477 #[unsafe(method_family = none)]
478 unsafe fn searchTextField_itemProviderForCopyingToken(
479 &self,
480 search_text_field: &UISearchTextField,
481 token: &UISearchToken,
482 ) -> Retained<NSItemProvider>;
483
484 #[cfg(all(
485 feature = "UIControl",
486 feature = "UIResponder",
487 feature = "UISearchSuggestion",
488 feature = "UIView"
489 ))]
490 #[optional]
492 #[unsafe(method(searchTextField:didSelectSuggestion:))]
493 #[unsafe(method_family = none)]
494 unsafe fn searchTextField_didSelectSuggestion(
495 &self,
496 search_text_field: &UISearchTextField,
497 suggestion: &ProtocolObject<dyn UISearchSuggestion>,
498 );
499 }
500);
501
502extern_protocol!(
503 #[cfg(feature = "UITextPasteDelegate")]
509 pub unsafe trait UISearchTextFieldPasteItem: UITextPasteItem + MainThreadOnly {
510 #[unsafe(method(setSearchTokenResult:))]
512 #[unsafe(method_family = none)]
513 unsafe fn setSearchTokenResult(&self, token: &UISearchToken);
514 }
515);