objc2_ui_kit/generated/
UIResponder.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextattributesconversionhandler?language=objc)
11#[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/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditinginteractionconfiguration?language=objc)
19// NS_ENUM
20#[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    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiresponderstandardeditactions?language=objc)
40    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    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiresponder?language=objc)
191    #[unsafe(super(NSObject))]
192    #[thread_kind = MainThreadOnly]
193    #[derive(Debug, PartialEq, Eq, Hash)]
194    pub struct UIResponder;
195);
196
197extern_conformance!(
198    unsafe impl NSObjectProtocol for UIResponder {}
199);
200
201extern_conformance!(
202    unsafe impl UIResponderStandardEditActions for UIResponder {}
203);
204
205impl UIResponder {
206    extern_methods!(
207        #[unsafe(method(nextResponder))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn nextResponder(&self) -> Option<Retained<UIResponder>>;
210
211        #[unsafe(method(canBecomeFirstResponder))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn canBecomeFirstResponder(&self) -> bool;
214
215        #[unsafe(method(becomeFirstResponder))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn becomeFirstResponder(&self) -> bool;
218
219        #[unsafe(method(canResignFirstResponder))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn canResignFirstResponder(&self) -> bool;
222
223        #[unsafe(method(resignFirstResponder))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn resignFirstResponder(&self) -> bool;
226
227        #[unsafe(method(isFirstResponder))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn isFirstResponder(&self) -> bool;
230
231        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
232        #[unsafe(method(touchesBegan:withEvent:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn touchesBegan_withEvent(
235            &self,
236            touches: &NSSet<UITouch>,
237            event: Option<&UIEvent>,
238        );
239
240        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
241        #[unsafe(method(touchesMoved:withEvent:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn touchesMoved_withEvent(
244            &self,
245            touches: &NSSet<UITouch>,
246            event: Option<&UIEvent>,
247        );
248
249        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
250        #[unsafe(method(touchesEnded:withEvent:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn touchesEnded_withEvent(
253            &self,
254            touches: &NSSet<UITouch>,
255            event: Option<&UIEvent>,
256        );
257
258        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
259        #[unsafe(method(touchesCancelled:withEvent:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn touchesCancelled_withEvent(
262            &self,
263            touches: &NSSet<UITouch>,
264            event: Option<&UIEvent>,
265        );
266
267        #[cfg(feature = "UITouch")]
268        #[unsafe(method(touchesEstimatedPropertiesUpdated:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn touchesEstimatedPropertiesUpdated(&self, touches: &NSSet<UITouch>);
271
272        #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
273        #[unsafe(method(pressesBegan:withEvent:))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn pressesBegan_withEvent(
276            &self,
277            presses: &NSSet<UIPress>,
278            event: Option<&UIPressesEvent>,
279        );
280
281        #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
282        #[unsafe(method(pressesChanged:withEvent:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn pressesChanged_withEvent(
285            &self,
286            presses: &NSSet<UIPress>,
287            event: Option<&UIPressesEvent>,
288        );
289
290        #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
291        #[unsafe(method(pressesEnded:withEvent:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn pressesEnded_withEvent(
294            &self,
295            presses: &NSSet<UIPress>,
296            event: Option<&UIPressesEvent>,
297        );
298
299        #[cfg(all(feature = "UIEvent", feature = "UIPress", feature = "UIPressesEvent"))]
300        #[unsafe(method(pressesCancelled:withEvent:))]
301        #[unsafe(method_family = none)]
302        pub unsafe fn pressesCancelled_withEvent(
303            &self,
304            presses: &NSSet<UIPress>,
305            event: Option<&UIPressesEvent>,
306        );
307
308        #[cfg(feature = "UIEvent")]
309        #[unsafe(method(motionBegan:withEvent:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn motionBegan_withEvent(&self, motion: UIEventSubtype, event: Option<&UIEvent>);
312
313        #[cfg(feature = "UIEvent")]
314        #[unsafe(method(motionEnded:withEvent:))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn motionEnded_withEvent(&self, motion: UIEventSubtype, event: Option<&UIEvent>);
317
318        #[cfg(feature = "UIEvent")]
319        #[unsafe(method(motionCancelled:withEvent:))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn motionCancelled_withEvent(
322            &self,
323            motion: UIEventSubtype,
324            event: Option<&UIEvent>,
325        );
326
327        #[cfg(feature = "UIEvent")]
328        #[unsafe(method(remoteControlReceivedWithEvent:))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn remoteControlReceivedWithEvent(&self, event: Option<&UIEvent>);
331
332        #[unsafe(method(canPerformAction:withSender:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn canPerformAction_withSender(
335            &self,
336            action: Sel,
337            sender: Option<&AnyObject>,
338        ) -> bool;
339
340        #[unsafe(method(targetForAction:withSender:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn targetForAction_withSender(
343            &self,
344            action: Sel,
345            sender: Option<&AnyObject>,
346        ) -> Option<Retained<AnyObject>>;
347
348        #[cfg(feature = "UIMenuBuilder")]
349        #[unsafe(method(buildMenuWithBuilder:))]
350        #[unsafe(method_family = none)]
351        pub unsafe fn buildMenuWithBuilder(&self, builder: &ProtocolObject<dyn UIMenuBuilder>);
352
353        #[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
354        #[unsafe(method(validateCommand:))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn validateCommand(&self, command: &UICommand);
357
358        #[unsafe(method(undoManager))]
359        #[unsafe(method_family = none)]
360        pub unsafe fn undoManager(&self) -> Option<Retained<NSUndoManager>>;
361
362        #[unsafe(method(editingInteractionConfiguration))]
363        #[unsafe(method_family = none)]
364        pub unsafe fn editingInteractionConfiguration(&self) -> UIEditingInteractionConfiguration;
365    );
366}
367
368/// Methods declared on superclass `NSObject`.
369impl UIResponder {
370    extern_methods!(
371        #[unsafe(method(init))]
372        #[unsafe(method_family = init)]
373        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
374
375        #[unsafe(method(new))]
376        #[unsafe(method_family = new)]
377        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
378    );
379}
380
381/// UIResponderKeyCommands.
382impl UIResponder {
383    extern_methods!(
384        #[cfg(all(
385            feature = "UICommand",
386            feature = "UIKeyCommand",
387            feature = "UIMenuElement"
388        ))]
389        #[unsafe(method(keyCommands))]
390        #[unsafe(method_family = none)]
391        pub unsafe fn keyCommands(&self) -> Option<Retained<NSArray<UIKeyCommand>>>;
392    );
393}
394
395/// UIResponderInputViewAdditions.
396impl UIResponder {
397    extern_methods!(
398        #[cfg(feature = "UIView")]
399        #[unsafe(method(inputView))]
400        #[unsafe(method_family = none)]
401        pub unsafe fn inputView(&self) -> Option<Retained<UIView>>;
402
403        #[cfg(feature = "UIView")]
404        #[unsafe(method(inputAccessoryView))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn inputAccessoryView(&self) -> Option<Retained<UIView>>;
407
408        #[cfg(feature = "UITextInput")]
409        /// This method is for clients that wish to put buttons on the Shortcuts Bar, shown on top of the keyboard.
410        /// You may modify the returned inputAssistantItem to add to or replace the existing items on the bar.
411        /// Modifications made to the returned UITextInputAssistantItem are reflected automatically.
412        /// This method should not be overridden. Goes up the responder chain.
413        #[unsafe(method(inputAssistantItem))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn inputAssistantItem(&self) -> Retained<UITextInputAssistantItem>;
416
417        #[cfg(all(feature = "UIInputViewController", feature = "UIViewController"))]
418        #[unsafe(method(inputViewController))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn inputViewController(&self) -> Option<Retained<UIInputViewController>>;
421
422        #[cfg(all(feature = "UIInputViewController", feature = "UIViewController"))]
423        #[unsafe(method(inputAccessoryViewController))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn inputAccessoryViewController(
426            &self,
427        ) -> Option<Retained<UIInputViewController>>;
428
429        #[cfg(feature = "UITextInput")]
430        #[unsafe(method(textInputMode))]
431        #[unsafe(method_family = none)]
432        pub unsafe fn textInputMode(&self) -> Option<Retained<UITextInputMode>>;
433
434        #[unsafe(method(textInputContextIdentifier))]
435        #[unsafe(method_family = none)]
436        pub unsafe fn textInputContextIdentifier(&self) -> Option<Retained<NSString>>;
437
438        #[unsafe(method(clearTextInputContextIdentifier:))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn clearTextInputContextIdentifier(identifier: &NSString, mtm: MainThreadMarker);
441
442        #[unsafe(method(reloadInputViews))]
443        #[unsafe(method_family = none)]
444        pub unsafe fn reloadInputViews(&self);
445    );
446}
447
448extern "C" {
449    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputuparrow?language=objc)
450    pub static UIKeyInputUpArrow: &'static NSString;
451}
452
453extern "C" {
454    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputdownarrow?language=objc)
455    pub static UIKeyInputDownArrow: &'static NSString;
456}
457
458extern "C" {
459    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputleftarrow?language=objc)
460    pub static UIKeyInputLeftArrow: &'static NSString;
461}
462
463extern "C" {
464    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputrightarrow?language=objc)
465    pub static UIKeyInputRightArrow: &'static NSString;
466}
467
468extern "C" {
469    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputescape?language=objc)
470    pub static UIKeyInputEscape: &'static NSString;
471}
472
473extern "C" {
474    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputpageup?language=objc)
475    pub static UIKeyInputPageUp: &'static NSString;
476}
477
478extern "C" {
479    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputpagedown?language=objc)
480    pub static UIKeyInputPageDown: &'static NSString;
481}
482
483extern "C" {
484    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputhome?language=objc)
485    pub static UIKeyInputHome: &'static NSString;
486}
487
488extern "C" {
489    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputend?language=objc)
490    pub static UIKeyInputEnd: &'static NSString;
491}
492
493extern "C" {
494    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf2?language=objc)
495    pub static UIKeyInputF2: &'static NSString;
496}
497
498extern "C" {
499    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf3?language=objc)
500    pub static UIKeyInputF3: &'static NSString;
501}
502
503extern "C" {
504    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf4?language=objc)
505    pub static UIKeyInputF4: &'static NSString;
506}
507
508extern "C" {
509    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf5?language=objc)
510    pub static UIKeyInputF5: &'static NSString;
511}
512
513extern "C" {
514    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf6?language=objc)
515    pub static UIKeyInputF6: &'static NSString;
516}
517
518extern "C" {
519    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf7?language=objc)
520    pub static UIKeyInputF7: &'static NSString;
521}
522
523extern "C" {
524    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf8?language=objc)
525    pub static UIKeyInputF8: &'static NSString;
526}
527
528extern "C" {
529    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf9?language=objc)
530    pub static UIKeyInputF9: &'static NSString;
531}
532
533extern "C" {
534    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf10?language=objc)
535    pub static UIKeyInputF10: &'static NSString;
536}
537
538extern "C" {
539    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf11?language=objc)
540    pub static UIKeyInputF11: &'static NSString;
541}
542
543extern "C" {
544    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputf12?language=objc)
545    pub static UIKeyInputF12: &'static NSString;
546}
547
548extern "C" {
549    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeyinputdelete?language=objc)
550    pub static UIKeyInputDelete: &'static NSString;
551}
552
553/// ActivityContinuation.
554impl UIResponder {
555    extern_methods!(
556        #[unsafe(method(userActivity))]
557        #[unsafe(method_family = none)]
558        pub unsafe fn userActivity(&self) -> Option<Retained<NSUserActivity>>;
559
560        /// Setter for [`userActivity`][Self::userActivity].
561        #[unsafe(method(setUserActivity:))]
562        #[unsafe(method_family = none)]
563        pub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>);
564
565        #[unsafe(method(updateUserActivityState:))]
566        #[unsafe(method_family = none)]
567        pub unsafe fn updateUserActivityState(&self, activity: &NSUserActivity);
568
569        #[unsafe(method(restoreUserActivityState:))]
570        #[unsafe(method_family = none)]
571        pub unsafe fn restoreUserActivityState(&self, activity: &NSUserActivity);
572    );
573}
574
575#[cfg(feature = "UIUserActivity")]
576extern_conformance!(
577    unsafe impl UIUserActivityRestoring for UIResponder {}
578);
579
580/// UIPasteConfigurationSupporting.
581impl UIResponder {
582    extern_methods!();
583}
584
585#[cfg(feature = "UIPasteConfigurationSupporting")]
586extern_conformance!(
587    unsafe impl UIPasteConfigurationSupporting for UIResponder {}
588);
589
590/// UICaptureTextFromCameraSupporting.
591impl UIResponder {
592    extern_methods!(
593        #[unsafe(method(captureTextFromCamera:))]
594        #[unsafe(method_family = none)]
595        pub unsafe fn captureTextFromCamera(&self, sender: Option<&AnyObject>);
596    );
597}