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::DynBlock<
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]
47 #[unsafe(method(cut:))]
48 #[unsafe(method_family = none)]
49 unsafe fn cut(&self, sender: Option<&AnyObject>);
50
51 #[optional]
55 #[unsafe(method(copy:))]
56 #[unsafe(method_family = none)]
57 unsafe fn copy(&self, sender: Option<&AnyObject>);
58
59 #[optional]
63 #[unsafe(method(paste:))]
64 #[unsafe(method_family = none)]
65 unsafe fn paste(&self, sender: Option<&AnyObject>);
66
67 #[optional]
71 #[unsafe(method(pasteAndMatchStyle:))]
72 #[unsafe(method_family = none)]
73 unsafe fn pasteAndMatchStyle(&self, sender: Option<&AnyObject>);
74
75 #[optional]
79 #[unsafe(method(pasteAndGo:))]
80 #[unsafe(method_family = none)]
81 unsafe fn pasteAndGo(&self, sender: Option<&AnyObject>);
82
83 #[optional]
87 #[unsafe(method(pasteAndSearch:))]
88 #[unsafe(method_family = none)]
89 unsafe fn pasteAndSearch(&self, sender: Option<&AnyObject>);
90
91 #[optional]
95 #[unsafe(method(newFromPasteboard:))]
96 #[unsafe(method_family = none)]
97 unsafe fn newFromPasteboard(&self, sender: Option<&AnyObject>);
98
99 #[optional]
103 #[unsafe(method(select:))]
104 #[unsafe(method_family = none)]
105 unsafe fn select(&self, sender: Option<&AnyObject>);
106
107 #[optional]
111 #[unsafe(method(selectAll:))]
112 #[unsafe(method_family = none)]
113 unsafe fn selectAll(&self, sender: Option<&AnyObject>);
114
115 #[optional]
119 #[unsafe(method(delete:))]
120 #[unsafe(method_family = none)]
121 unsafe fn delete(&self, sender: Option<&AnyObject>);
122
123 #[optional]
127 #[unsafe(method(makeTextWritingDirectionLeftToRight:))]
128 #[unsafe(method_family = none)]
129 unsafe fn makeTextWritingDirectionLeftToRight(&self, sender: Option<&AnyObject>);
130
131 #[optional]
135 #[unsafe(method(makeTextWritingDirectionRightToLeft:))]
136 #[unsafe(method_family = none)]
137 unsafe fn makeTextWritingDirectionRightToLeft(&self, sender: Option<&AnyObject>);
138
139 #[optional]
143 #[unsafe(method(toggleBoldface:))]
144 #[unsafe(method_family = none)]
145 unsafe fn toggleBoldface(&self, sender: Option<&AnyObject>);
146
147 #[optional]
151 #[unsafe(method(toggleItalics:))]
152 #[unsafe(method_family = none)]
153 unsafe fn toggleItalics(&self, sender: Option<&AnyObject>);
154
155 #[optional]
159 #[unsafe(method(toggleUnderline:))]
160 #[unsafe(method_family = none)]
161 unsafe fn toggleUnderline(&self, sender: Option<&AnyObject>);
162
163 #[optional]
167 #[unsafe(method(increaseSize:))]
168 #[unsafe(method_family = none)]
169 unsafe fn increaseSize(&self, sender: Option<&AnyObject>);
170
171 #[optional]
175 #[unsafe(method(decreaseSize:))]
176 #[unsafe(method_family = none)]
177 unsafe fn decreaseSize(&self, sender: Option<&AnyObject>);
178
179 #[optional]
183 #[unsafe(method(alignLeft:))]
184 #[unsafe(method_family = none)]
185 unsafe fn alignLeft(&self, sender: Option<&AnyObject>);
186
187 #[optional]
191 #[unsafe(method(alignCenter:))]
192 #[unsafe(method_family = none)]
193 unsafe fn alignCenter(&self, sender: Option<&AnyObject>);
194
195 #[optional]
199 #[unsafe(method(alignJustified:))]
200 #[unsafe(method_family = none)]
201 unsafe fn alignJustified(&self, sender: Option<&AnyObject>);
202
203 #[optional]
207 #[unsafe(method(alignRight:))]
208 #[unsafe(method_family = none)]
209 unsafe fn alignRight(&self, sender: Option<&AnyObject>);
210
211 #[optional]
215 #[unsafe(method(find:))]
216 #[unsafe(method_family = none)]
217 unsafe fn find(&self, sender: Option<&AnyObject>);
218
219 #[optional]
223 #[unsafe(method(findAndReplace:))]
224 #[unsafe(method_family = none)]
225 unsafe fn findAndReplace(&self, sender: Option<&AnyObject>);
226
227 #[optional]
231 #[unsafe(method(findNext:))]
232 #[unsafe(method_family = none)]
233 unsafe fn findNext(&self, sender: Option<&AnyObject>);
234
235 #[optional]
239 #[unsafe(method(findPrevious:))]
240 #[unsafe(method_family = none)]
241 unsafe fn findPrevious(&self, sender: Option<&AnyObject>);
242
243 #[optional]
247 #[unsafe(method(useSelectionForFind:))]
248 #[unsafe(method_family = none)]
249 unsafe fn useSelectionForFind(&self, sender: Option<&AnyObject>);
250
251 #[cfg(feature = "block2")]
252 #[optional]
256 #[unsafe(method(updateTextAttributesWithConversionHandler:))]
257 #[unsafe(method_family = none)]
258 unsafe fn updateTextAttributesWithConversionHandler(
259 &self,
260 conversion_handler: UITextAttributesConversionHandler,
261 );
262
263 #[optional]
267 #[unsafe(method(print:))]
268 #[unsafe(method_family = none)]
269 unsafe fn print(&self, sender: Option<&AnyObject>);
270
271 #[optional]
275 #[unsafe(method(rename:))]
276 #[unsafe(method_family = none)]
277 unsafe fn rename(&self, sender: Option<&AnyObject>);
278
279 #[optional]
283 #[unsafe(method(duplicate:))]
284 #[unsafe(method_family = none)]
285 unsafe fn duplicate(&self, sender: Option<&AnyObject>);
286
287 #[optional]
291 #[unsafe(method(move:))]
292 #[unsafe(method_family = none)]
293 unsafe fn r#move(&self, sender: Option<&AnyObject>);
294
295 #[optional]
299 #[unsafe(method(export:))]
300 #[unsafe(method_family = none)]
301 unsafe fn export(&self, sender: Option<&AnyObject>);
302
303 #[optional]
307 #[unsafe(method(toggleSidebar:))]
308 #[unsafe(method_family = none)]
309 unsafe fn toggleSidebar(&self, sender: Option<&AnyObject>);
310
311 #[optional]
315 #[unsafe(method(toggleInspector:))]
316 #[unsafe(method_family = none)]
317 unsafe fn toggleInspector(&self, sender: Option<&AnyObject>);
318
319 #[optional]
323 #[unsafe(method(performClose:))]
324 #[unsafe(method_family = none)]
325 unsafe fn performClose(&self, sender: Option<&AnyObject>);
326
327 #[optional]
331 #[unsafe(method(showWritingTools:))]
332 #[unsafe(method_family = none)]
333 unsafe fn showWritingTools(&self, sender: &AnyObject);
334 }
335);
336
337extern_class!(
338 #[unsafe(super(NSObject))]
340 #[thread_kind = MainThreadOnly]
341 #[derive(Debug, PartialEq, Eq, Hash)]
342 pub struct UIResponder;
343);
344
345extern_conformance!(
346 unsafe impl NSObjectProtocol for UIResponder {}
347);
348
349extern_conformance!(
350 unsafe impl UIResponderStandardEditActions for UIResponder {}
351);
352
353impl UIResponder {
354 extern_methods!(
355 #[unsafe(method(nextResponder))]
356 #[unsafe(method_family = none)]
357 pub fn nextResponder(&self) -> Option<Retained<UIResponder>>;
358
359 #[unsafe(method(canBecomeFirstResponder))]
360 #[unsafe(method_family = none)]
361 pub fn canBecomeFirstResponder(&self) -> bool;
362
363 #[unsafe(method(becomeFirstResponder))]
364 #[unsafe(method_family = none)]
365 pub fn becomeFirstResponder(&self) -> bool;
366
367 #[unsafe(method(canResignFirstResponder))]
368 #[unsafe(method_family = none)]
369 pub fn canResignFirstResponder(&self) -> bool;
370
371 #[unsafe(method(resignFirstResponder))]
372 #[unsafe(method_family = none)]
373 pub fn resignFirstResponder(&self) -> bool;
374
375 #[unsafe(method(isFirstResponder))]
376 #[unsafe(method_family = none)]
377 pub fn isFirstResponder(&self) -> bool;
378
379 #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
380 #[unsafe(method(touchesBegan:withEvent:))]
381 #[unsafe(method_family = none)]
382 pub fn touchesBegan_withEvent(&self, touches: &NSSet<UITouch>, event: Option<&UIEvent>);
383
384 #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
385 #[unsafe(method(touchesMoved:withEvent:))]
386 #[unsafe(method_family = none)]
387 pub fn touchesMoved_withEvent(&self, touches: &NSSet<UITouch>, event: Option<&UIEvent>);
388
389 #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
390 #[unsafe(method(touchesEnded:withEvent:))]
391 #[unsafe(method_family = none)]
392 pub fn touchesEnded_withEvent(&self, touches: &NSSet<UITouch>, event: Option<&UIEvent>);
393
394 #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
395 #[unsafe(method(touchesCancelled:withEvent:))]
396 #[unsafe(method_family = none)]
397 pub fn touchesCancelled_withEvent(&self, touches: &NSSet<UITouch>, event: Option<&UIEvent>);
398
399 #[cfg(feature = "UITouch")]
400 #[unsafe(method(touchesEstimatedPropertiesUpdated:))]
401 #[unsafe(method_family = none)]
402 pub fn touchesEstimatedPropertiesUpdated(&self, touches: &NSSet<UITouch>);
403
404 #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
405 #[unsafe(method(pressesBegan:withEvent:))]
406 #[unsafe(method_family = none)]
407 pub fn pressesBegan_withEvent(
408 &self,
409 presses: &NSSet<UIPress>,
410 event: Option<&UIPressesEvent>,
411 );
412
413 #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
414 #[unsafe(method(pressesChanged:withEvent:))]
415 #[unsafe(method_family = none)]
416 pub fn pressesChanged_withEvent(
417 &self,
418 presses: &NSSet<UIPress>,
419 event: Option<&UIPressesEvent>,
420 );
421
422 #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
423 #[unsafe(method(pressesEnded:withEvent:))]
424 #[unsafe(method_family = none)]
425 pub fn pressesEnded_withEvent(
426 &self,
427 presses: &NSSet<UIPress>,
428 event: Option<&UIPressesEvent>,
429 );
430
431 #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
432 #[unsafe(method(pressesCancelled:withEvent:))]
433 #[unsafe(method_family = none)]
434 pub fn pressesCancelled_withEvent(
435 &self,
436 presses: &NSSet<UIPress>,
437 event: Option<&UIPressesEvent>,
438 );
439
440 #[cfg(feature = "UIEvent")]
441 #[unsafe(method(motionBegan:withEvent:))]
442 #[unsafe(method_family = none)]
443 pub fn motionBegan_withEvent(&self, motion: UIEventSubtype, event: Option<&UIEvent>);
444
445 #[cfg(feature = "UIEvent")]
446 #[unsafe(method(motionEnded:withEvent:))]
447 #[unsafe(method_family = none)]
448 pub fn motionEnded_withEvent(&self, motion: UIEventSubtype, event: Option<&UIEvent>);
449
450 #[cfg(feature = "UIEvent")]
451 #[unsafe(method(motionCancelled:withEvent:))]
452 #[unsafe(method_family = none)]
453 pub fn motionCancelled_withEvent(&self, motion: UIEventSubtype, event: Option<&UIEvent>);
454
455 #[cfg(feature = "UIEvent")]
456 #[unsafe(method(remoteControlReceivedWithEvent:))]
457 #[unsafe(method_family = none)]
458 pub fn remoteControlReceivedWithEvent(&self, event: Option<&UIEvent>);
459
460 #[unsafe(method(canPerformAction:withSender:))]
465 #[unsafe(method_family = none)]
466 pub unsafe fn canPerformAction_withSender(
467 &self,
468 action: Sel,
469 sender: Option<&AnyObject>,
470 ) -> bool;
471
472 #[unsafe(method(targetForAction:withSender:))]
477 #[unsafe(method_family = none)]
478 pub unsafe fn targetForAction_withSender(
479 &self,
480 action: Sel,
481 sender: Option<&AnyObject>,
482 ) -> Option<Retained<AnyObject>>;
483
484 #[cfg(feature = "UIMenuBuilder")]
485 #[unsafe(method(buildMenuWithBuilder:))]
486 #[unsafe(method_family = none)]
487 pub fn buildMenuWithBuilder(&self, builder: &ProtocolObject<dyn UIMenuBuilder>);
488
489 #[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
490 #[unsafe(method(validateCommand:))]
491 #[unsafe(method_family = none)]
492 pub fn validateCommand(&self, command: &UICommand);
493
494 #[cfg(all(feature = "UIDeferredMenuElement", feature = "UIMenuElement"))]
495 #[unsafe(method(providerForDeferredMenuElement:))]
500 #[unsafe(method_family = none)]
501 pub fn providerForDeferredMenuElement(
502 &self,
503 deferred_element: &UIDeferredMenuElement,
504 ) -> Option<Retained<UIDeferredMenuElementProvider>>;
505
506 #[unsafe(method(undoManager))]
507 #[unsafe(method_family = none)]
508 pub fn undoManager(&self) -> Option<Retained<NSUndoManager>>;
509
510 #[unsafe(method(editingInteractionConfiguration))]
511 #[unsafe(method_family = none)]
512 pub fn editingInteractionConfiguration(&self) -> UIEditingInteractionConfiguration;
513 );
514}
515
516impl UIResponder {
518 extern_methods!(
519 #[unsafe(method(init))]
520 #[unsafe(method_family = init)]
521 pub fn init(this: Allocated<Self>) -> Retained<Self>;
522
523 #[unsafe(method(new))]
524 #[unsafe(method_family = new)]
525 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
526 );
527}
528
529impl UIResponder {
531 extern_methods!(
532 #[cfg(all(
533 feature = "UICommand",
534 feature = "UIKeyCommand",
535 feature = "UIMenuElement"
536 ))]
537 #[unsafe(method(keyCommands))]
538 #[unsafe(method_family = none)]
539 pub fn keyCommands(&self) -> Option<Retained<NSArray<UIKeyCommand>>>;
540 );
541}
542
543impl UIResponder {
545 extern_methods!(
546 #[cfg(feature = "UIView")]
547 #[unsafe(method(inputView))]
548 #[unsafe(method_family = none)]
549 pub fn inputView(&self) -> Option<Retained<UIView>>;
550
551 #[cfg(feature = "UIView")]
552 #[unsafe(method(inputAccessoryView))]
553 #[unsafe(method_family = none)]
554 pub fn inputAccessoryView(&self) -> Option<Retained<UIView>>;
555
556 #[cfg(feature = "UITextInput")]
557 #[unsafe(method(inputAssistantItem))]
562 #[unsafe(method_family = none)]
563 pub fn inputAssistantItem(&self) -> Retained<UITextInputAssistantItem>;
564
565 #[cfg(all(feature = "UIInputViewController", feature = "UIViewController"))]
566 #[unsafe(method(inputViewController))]
567 #[unsafe(method_family = none)]
568 pub fn inputViewController(&self) -> Option<Retained<UIInputViewController>>;
569
570 #[cfg(all(feature = "UIInputViewController", feature = "UIViewController"))]
571 #[unsafe(method(inputAccessoryViewController))]
572 #[unsafe(method_family = none)]
573 pub fn inputAccessoryViewController(&self) -> Option<Retained<UIInputViewController>>;
574
575 #[cfg(feature = "UITextInput")]
576 #[unsafe(method(textInputMode))]
577 #[unsafe(method_family = none)]
578 pub fn textInputMode(&self) -> Option<Retained<UITextInputMode>>;
579
580 #[unsafe(method(textInputContextIdentifier))]
581 #[unsafe(method_family = none)]
582 pub fn textInputContextIdentifier(&self) -> Option<Retained<NSString>>;
583
584 #[unsafe(method(clearTextInputContextIdentifier:))]
585 #[unsafe(method_family = none)]
586 pub fn clearTextInputContextIdentifier(identifier: &NSString, mtm: MainThreadMarker);
587
588 #[unsafe(method(reloadInputViews))]
589 #[unsafe(method_family = none)]
590 pub fn reloadInputViews(&self);
591 );
592}
593
594extern "C" {
595 pub static UIKeyInputUpArrow: &'static NSString;
597}
598
599extern "C" {
600 pub static UIKeyInputDownArrow: &'static NSString;
602}
603
604extern "C" {
605 pub static UIKeyInputLeftArrow: &'static NSString;
607}
608
609extern "C" {
610 pub static UIKeyInputRightArrow: &'static NSString;
612}
613
614extern "C" {
615 pub static UIKeyInputEscape: &'static NSString;
617}
618
619extern "C" {
620 pub static UIKeyInputPageUp: &'static NSString;
622}
623
624extern "C" {
625 pub static UIKeyInputPageDown: &'static NSString;
627}
628
629extern "C" {
630 pub static UIKeyInputHome: &'static NSString;
632}
633
634extern "C" {
635 pub static UIKeyInputEnd: &'static NSString;
637}
638
639extern "C" {
640 pub static UIKeyInputF2: &'static NSString;
642}
643
644extern "C" {
645 pub static UIKeyInputF3: &'static NSString;
647}
648
649extern "C" {
650 pub static UIKeyInputF4: &'static NSString;
652}
653
654extern "C" {
655 pub static UIKeyInputF5: &'static NSString;
657}
658
659extern "C" {
660 pub static UIKeyInputF6: &'static NSString;
662}
663
664extern "C" {
665 pub static UIKeyInputF7: &'static NSString;
667}
668
669extern "C" {
670 pub static UIKeyInputF8: &'static NSString;
672}
673
674extern "C" {
675 pub static UIKeyInputF9: &'static NSString;
677}
678
679extern "C" {
680 pub static UIKeyInputF10: &'static NSString;
682}
683
684extern "C" {
685 pub static UIKeyInputF11: &'static NSString;
687}
688
689extern "C" {
690 pub static UIKeyInputF12: &'static NSString;
692}
693
694extern "C" {
695 pub static UIKeyInputDelete: &'static NSString;
697}
698
699impl UIResponder {
701 extern_methods!(
702 #[unsafe(method(userActivity))]
703 #[unsafe(method_family = none)]
704 pub fn userActivity(&self) -> Option<Retained<NSUserActivity>>;
705
706 #[unsafe(method(setUserActivity:))]
708 #[unsafe(method_family = none)]
709 pub fn setUserActivity(&self, user_activity: Option<&NSUserActivity>);
710
711 #[unsafe(method(updateUserActivityState:))]
712 #[unsafe(method_family = none)]
713 pub fn updateUserActivityState(&self, activity: &NSUserActivity);
714
715 #[unsafe(method(restoreUserActivityState:))]
716 #[unsafe(method_family = none)]
717 pub fn restoreUserActivityState(&self, activity: &NSUserActivity);
718 );
719}
720
721#[cfg(feature = "UIUserActivity")]
722extern_conformance!(
723 unsafe impl UIUserActivityRestoring for UIResponder {}
724);
725
726impl UIResponder {
728 extern_methods!();
729}
730
731#[cfg(feature = "UIPasteConfigurationSupporting")]
732extern_conformance!(
733 unsafe impl UIPasteConfigurationSupporting for UIResponder {}
734);
735
736impl UIResponder {
738 extern_methods!(
739 #[unsafe(method(captureTextFromCamera:))]
743 #[unsafe(method_family = none)]
744 pub unsafe fn captureTextFromCamera(&self, sender: Option<&AnyObject>);
745 );
746}