1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[cfg(feature = "block2")]
12pub type UITextAttributesConversionHandler = *mut block2::Block<
13 dyn Fn(
14 NonNull<NSDictionary<NSAttributedStringKey, AnyObject>>,
15 ) -> NonNull<NSDictionary<NSAttributedStringKey, AnyObject>>,
16>;
17
18#[repr(transparent)]
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct UIEditingInteractionConfiguration(pub NSInteger);
23impl UIEditingInteractionConfiguration {
24 #[doc(alias = "UIEditingInteractionConfigurationNone")]
25 pub const None: Self = Self(0);
26 #[doc(alias = "UIEditingInteractionConfigurationDefault")]
27 pub const Default: Self = Self(1);
28}
29
30unsafe impl Encode for UIEditingInteractionConfiguration {
31 const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for UIEditingInteractionConfiguration {
35 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_protocol!(
39 pub unsafe trait UIResponderStandardEditActions:
41 NSObjectProtocol + MainThreadOnly
42 {
43 #[optional]
44 #[unsafe(method(cut:))]
45 #[unsafe(method_family = none)]
46 unsafe fn cut(&self, sender: Option<&AnyObject>);
47
48 #[optional]
49 #[unsafe(method(copy:))]
50 #[unsafe(method_family = none)]
51 unsafe fn copy(&self, sender: Option<&AnyObject>);
52
53 #[optional]
54 #[unsafe(method(paste:))]
55 #[unsafe(method_family = none)]
56 unsafe fn paste(&self, sender: Option<&AnyObject>);
57
58 #[optional]
59 #[unsafe(method(pasteAndMatchStyle:))]
60 #[unsafe(method_family = none)]
61 unsafe fn pasteAndMatchStyle(&self, sender: Option<&AnyObject>);
62
63 #[optional]
64 #[unsafe(method(pasteAndGo:))]
65 #[unsafe(method_family = none)]
66 unsafe fn pasteAndGo(&self, sender: Option<&AnyObject>);
67
68 #[optional]
69 #[unsafe(method(pasteAndSearch:))]
70 #[unsafe(method_family = none)]
71 unsafe fn pasteAndSearch(&self, sender: Option<&AnyObject>);
72
73 #[optional]
74 #[unsafe(method(select:))]
75 #[unsafe(method_family = none)]
76 unsafe fn select(&self, sender: Option<&AnyObject>);
77
78 #[optional]
79 #[unsafe(method(selectAll:))]
80 #[unsafe(method_family = none)]
81 unsafe fn selectAll(&self, sender: Option<&AnyObject>);
82
83 #[optional]
84 #[unsafe(method(delete:))]
85 #[unsafe(method_family = none)]
86 unsafe fn delete(&self, sender: Option<&AnyObject>);
87
88 #[optional]
89 #[unsafe(method(makeTextWritingDirectionLeftToRight:))]
90 #[unsafe(method_family = none)]
91 unsafe fn makeTextWritingDirectionLeftToRight(&self, sender: Option<&AnyObject>);
92
93 #[optional]
94 #[unsafe(method(makeTextWritingDirectionRightToLeft:))]
95 #[unsafe(method_family = none)]
96 unsafe fn makeTextWritingDirectionRightToLeft(&self, sender: Option<&AnyObject>);
97
98 #[optional]
99 #[unsafe(method(toggleBoldface:))]
100 #[unsafe(method_family = none)]
101 unsafe fn toggleBoldface(&self, sender: Option<&AnyObject>);
102
103 #[optional]
104 #[unsafe(method(toggleItalics:))]
105 #[unsafe(method_family = none)]
106 unsafe fn toggleItalics(&self, sender: Option<&AnyObject>);
107
108 #[optional]
109 #[unsafe(method(toggleUnderline:))]
110 #[unsafe(method_family = none)]
111 unsafe fn toggleUnderline(&self, sender: Option<&AnyObject>);
112
113 #[optional]
114 #[unsafe(method(increaseSize:))]
115 #[unsafe(method_family = none)]
116 unsafe fn increaseSize(&self, sender: Option<&AnyObject>);
117
118 #[optional]
119 #[unsafe(method(decreaseSize:))]
120 #[unsafe(method_family = none)]
121 unsafe fn decreaseSize(&self, sender: Option<&AnyObject>);
122
123 #[optional]
124 #[unsafe(method(find:))]
125 #[unsafe(method_family = none)]
126 unsafe fn find(&self, sender: Option<&AnyObject>);
127
128 #[optional]
129 #[unsafe(method(findAndReplace:))]
130 #[unsafe(method_family = none)]
131 unsafe fn findAndReplace(&self, sender: Option<&AnyObject>);
132
133 #[optional]
134 #[unsafe(method(findNext:))]
135 #[unsafe(method_family = none)]
136 unsafe fn findNext(&self, sender: Option<&AnyObject>);
137
138 #[optional]
139 #[unsafe(method(findPrevious:))]
140 #[unsafe(method_family = none)]
141 unsafe fn findPrevious(&self, sender: Option<&AnyObject>);
142
143 #[optional]
144 #[unsafe(method(useSelectionForFind:))]
145 #[unsafe(method_family = none)]
146 unsafe fn useSelectionForFind(&self, sender: Option<&AnyObject>);
147
148 #[cfg(feature = "block2")]
149 #[optional]
150 #[unsafe(method(updateTextAttributesWithConversionHandler:))]
151 #[unsafe(method_family = none)]
152 unsafe fn updateTextAttributesWithConversionHandler(
153 &self,
154 conversion_handler: UITextAttributesConversionHandler,
155 );
156
157 #[optional]
158 #[unsafe(method(print:))]
159 #[unsafe(method_family = none)]
160 unsafe fn print(&self, sender: Option<&AnyObject>);
161
162 #[optional]
163 #[unsafe(method(rename:))]
164 #[unsafe(method_family = none)]
165 unsafe fn rename(&self, sender: Option<&AnyObject>);
166
167 #[optional]
168 #[unsafe(method(duplicate:))]
169 #[unsafe(method_family = none)]
170 unsafe fn duplicate(&self, sender: Option<&AnyObject>);
171
172 #[optional]
173 #[unsafe(method(move:))]
174 #[unsafe(method_family = none)]
175 unsafe fn r#move(&self, sender: Option<&AnyObject>);
176
177 #[optional]
178 #[unsafe(method(export:))]
179 #[unsafe(method_family = none)]
180 unsafe fn export(&self, sender: Option<&AnyObject>);
181
182 #[optional]
183 #[unsafe(method(showWritingTools:))]
184 #[unsafe(method_family = none)]
185 unsafe fn showWritingTools(&self, sender: &AnyObject);
186 }
187);
188
189extern_class!(
190 #[unsafe(super(NSObject))]
192 #[thread_kind = MainThreadOnly]
193 #[derive(Debug, PartialEq, Eq, Hash)]
194 pub struct UIResponder;
195);
196
197unsafe impl NSObjectProtocol for UIResponder {}
198
199unsafe impl UIResponderStandardEditActions for UIResponder {}
200
201impl UIResponder {
202 extern_methods!(
203 #[unsafe(method(nextResponder))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn nextResponder(&self) -> Option<Retained<UIResponder>>;
206
207 #[unsafe(method(canBecomeFirstResponder))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn canBecomeFirstResponder(&self) -> bool;
210
211 #[unsafe(method(becomeFirstResponder))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn becomeFirstResponder(&self) -> bool;
214
215 #[unsafe(method(canResignFirstResponder))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn canResignFirstResponder(&self) -> bool;
218
219 #[unsafe(method(resignFirstResponder))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn resignFirstResponder(&self) -> bool;
222
223 #[unsafe(method(isFirstResponder))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn isFirstResponder(&self) -> bool;
226
227 #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
228 #[unsafe(method(touchesBegan:withEvent:))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn touchesBegan_withEvent(
231 &self,
232 touches: &NSSet<UITouch>,
233 event: Option<&UIEvent>,
234 );
235
236 #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
237 #[unsafe(method(touchesMoved:withEvent:))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn touchesMoved_withEvent(
240 &self,
241 touches: &NSSet<UITouch>,
242 event: Option<&UIEvent>,
243 );
244
245 #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
246 #[unsafe(method(touchesEnded:withEvent:))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn touchesEnded_withEvent(
249 &self,
250 touches: &NSSet<UITouch>,
251 event: Option<&UIEvent>,
252 );
253
254 #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
255 #[unsafe(method(touchesCancelled:withEvent:))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn touchesCancelled_withEvent(
258 &self,
259 touches: &NSSet<UITouch>,
260 event: Option<&UIEvent>,
261 );
262
263 #[cfg(feature = "UITouch")]
264 #[unsafe(method(touchesEstimatedPropertiesUpdated:))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn touchesEstimatedPropertiesUpdated(&self, touches: &NSSet<UITouch>);
267
268 #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
269 #[unsafe(method(pressesBegan:withEvent:))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn pressesBegan_withEvent(
272 &self,
273 presses: &NSSet<UIPress>,
274 event: Option<&UIPressesEvent>,
275 );
276
277 #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
278 #[unsafe(method(pressesChanged:withEvent:))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn pressesChanged_withEvent(
281 &self,
282 presses: &NSSet<UIPress>,
283 event: Option<&UIPressesEvent>,
284 );
285
286 #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
287 #[unsafe(method(pressesEnded:withEvent:))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn pressesEnded_withEvent(
290 &self,
291 presses: &NSSet<UIPress>,
292 event: Option<&UIPressesEvent>,
293 );
294
295 #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
296 #[unsafe(method(pressesCancelled:withEvent:))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn pressesCancelled_withEvent(
299 &self,
300 presses: &NSSet<UIPress>,
301 event: Option<&UIPressesEvent>,
302 );
303
304 #[cfg(feature = "UIEvent")]
305 #[unsafe(method(motionBegan:withEvent:))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn motionBegan_withEvent(&self, motion: UIEventSubtype, event: Option<&UIEvent>);
308
309 #[cfg(feature = "UIEvent")]
310 #[unsafe(method(motionEnded:withEvent:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn motionEnded_withEvent(&self, motion: UIEventSubtype, event: Option<&UIEvent>);
313
314 #[cfg(feature = "UIEvent")]
315 #[unsafe(method(motionCancelled:withEvent:))]
316 #[unsafe(method_family = none)]
317 pub unsafe fn motionCancelled_withEvent(
318 &self,
319 motion: UIEventSubtype,
320 event: Option<&UIEvent>,
321 );
322
323 #[cfg(feature = "UIEvent")]
324 #[unsafe(method(remoteControlReceivedWithEvent:))]
325 #[unsafe(method_family = none)]
326 pub unsafe fn remoteControlReceivedWithEvent(&self, event: Option<&UIEvent>);
327
328 #[unsafe(method(canPerformAction:withSender:))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn canPerformAction_withSender(
331 &self,
332 action: Sel,
333 sender: Option<&AnyObject>,
334 ) -> bool;
335
336 #[unsafe(method(targetForAction:withSender:))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn targetForAction_withSender(
339 &self,
340 action: Sel,
341 sender: Option<&AnyObject>,
342 ) -> Option<Retained<AnyObject>>;
343
344 #[cfg(feature = "UIMenuBuilder")]
345 #[unsafe(method(buildMenuWithBuilder:))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn buildMenuWithBuilder(&self, builder: &ProtocolObject<dyn UIMenuBuilder>);
348
349 #[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
350 #[unsafe(method(validateCommand:))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn validateCommand(&self, command: &UICommand);
353
354 #[unsafe(method(undoManager))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn undoManager(&self) -> Option<Retained<NSUndoManager>>;
357
358 #[unsafe(method(editingInteractionConfiguration))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn editingInteractionConfiguration(&self) -> UIEditingInteractionConfiguration;
361 );
362}
363
364impl UIResponder {
366 extern_methods!(
367 #[unsafe(method(init))]
368 #[unsafe(method_family = init)]
369 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
370
371 #[unsafe(method(new))]
372 #[unsafe(method_family = new)]
373 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
374 );
375}
376
377impl UIResponder {
379 extern_methods!(
380 #[cfg(all(
381 feature = "UICommand",
382 feature = "UIKeyCommand",
383 feature = "UIMenuElement"
384 ))]
385 #[unsafe(method(keyCommands))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn keyCommands(&self) -> Option<Retained<NSArray<UIKeyCommand>>>;
388 );
389}
390
391impl UIResponder {
393 extern_methods!(
394 #[cfg(feature = "UIView")]
395 #[unsafe(method(inputView))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn inputView(&self) -> Option<Retained<UIView>>;
398
399 #[cfg(feature = "UIView")]
400 #[unsafe(method(inputAccessoryView))]
401 #[unsafe(method_family = none)]
402 pub unsafe fn inputAccessoryView(&self) -> Option<Retained<UIView>>;
403
404 #[cfg(feature = "UITextInput")]
405 #[unsafe(method(inputAssistantItem))]
410 #[unsafe(method_family = none)]
411 pub unsafe fn inputAssistantItem(&self) -> Retained<UITextInputAssistantItem>;
412
413 #[cfg(all(feature = "UIInputViewController", feature = "UIViewController"))]
414 #[unsafe(method(inputViewController))]
415 #[unsafe(method_family = none)]
416 pub unsafe fn inputViewController(&self) -> Option<Retained<UIInputViewController>>;
417
418 #[cfg(all(feature = "UIInputViewController", feature = "UIViewController"))]
419 #[unsafe(method(inputAccessoryViewController))]
420 #[unsafe(method_family = none)]
421 pub unsafe fn inputAccessoryViewController(
422 &self,
423 ) -> Option<Retained<UIInputViewController>>;
424
425 #[cfg(feature = "UITextInput")]
426 #[unsafe(method(textInputMode))]
427 #[unsafe(method_family = none)]
428 pub unsafe fn textInputMode(&self) -> Option<Retained<UITextInputMode>>;
429
430 #[unsafe(method(textInputContextIdentifier))]
431 #[unsafe(method_family = none)]
432 pub unsafe fn textInputContextIdentifier(&self) -> Option<Retained<NSString>>;
433
434 #[unsafe(method(clearTextInputContextIdentifier:))]
435 #[unsafe(method_family = none)]
436 pub unsafe fn clearTextInputContextIdentifier(identifier: &NSString, mtm: MainThreadMarker);
437
438 #[unsafe(method(reloadInputViews))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn reloadInputViews(&self);
441 );
442}
443
444extern "C" {
445 pub static UIKeyInputUpArrow: &'static NSString;
447}
448
449extern "C" {
450 pub static UIKeyInputDownArrow: &'static NSString;
452}
453
454extern "C" {
455 pub static UIKeyInputLeftArrow: &'static NSString;
457}
458
459extern "C" {
460 pub static UIKeyInputRightArrow: &'static NSString;
462}
463
464extern "C" {
465 pub static UIKeyInputEscape: &'static NSString;
467}
468
469extern "C" {
470 pub static UIKeyInputPageUp: &'static NSString;
472}
473
474extern "C" {
475 pub static UIKeyInputPageDown: &'static NSString;
477}
478
479extern "C" {
480 pub static UIKeyInputHome: &'static NSString;
482}
483
484extern "C" {
485 pub static UIKeyInputEnd: &'static NSString;
487}
488
489extern "C" {
490 pub static UIKeyInputF2: &'static NSString;
492}
493
494extern "C" {
495 pub static UIKeyInputF3: &'static NSString;
497}
498
499extern "C" {
500 pub static UIKeyInputF4: &'static NSString;
502}
503
504extern "C" {
505 pub static UIKeyInputF5: &'static NSString;
507}
508
509extern "C" {
510 pub static UIKeyInputF6: &'static NSString;
512}
513
514extern "C" {
515 pub static UIKeyInputF7: &'static NSString;
517}
518
519extern "C" {
520 pub static UIKeyInputF8: &'static NSString;
522}
523
524extern "C" {
525 pub static UIKeyInputF9: &'static NSString;
527}
528
529extern "C" {
530 pub static UIKeyInputF10: &'static NSString;
532}
533
534extern "C" {
535 pub static UIKeyInputF11: &'static NSString;
537}
538
539extern "C" {
540 pub static UIKeyInputF12: &'static NSString;
542}
543
544extern "C" {
545 pub static UIKeyInputDelete: &'static NSString;
547}
548
549impl UIResponder {
551 extern_methods!(
552 #[unsafe(method(userActivity))]
553 #[unsafe(method_family = none)]
554 pub unsafe fn userActivity(&self) -> Option<Retained<NSUserActivity>>;
555
556 #[unsafe(method(setUserActivity:))]
558 #[unsafe(method_family = none)]
559 pub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>);
560
561 #[unsafe(method(updateUserActivityState:))]
562 #[unsafe(method_family = none)]
563 pub unsafe fn updateUserActivityState(&self, activity: &NSUserActivity);
564
565 #[unsafe(method(restoreUserActivityState:))]
566 #[unsafe(method_family = none)]
567 pub unsafe fn restoreUserActivityState(&self, activity: &NSUserActivity);
568 );
569}
570
571#[cfg(feature = "UIUserActivity")]
572unsafe impl UIUserActivityRestoring for UIResponder {}
573
574impl UIResponder {
576 extern_methods!();
577}
578
579#[cfg(feature = "UIPasteConfigurationSupporting")]
580unsafe impl UIPasteConfigurationSupporting for UIResponder {}
581
582impl UIResponder {
584 extern_methods!(
585 #[unsafe(method(captureTextFromCamera:))]
586 #[unsafe(method_family = none)]
587 pub unsafe fn captureTextFromCamera(&self, sender: Option<&AnyObject>);
588 );
589}