objc2_ui_kit/generated/
UIControl.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::*;
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
15/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontrolevents?language=objc)
16// NS_OPTIONS
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UIControlEvents(pub NSUInteger);
20bitflags::bitflags! {
21    impl UIControlEvents: NSUInteger {
22        #[doc(alias = "UIControlEventTouchDown")]
23        const TouchDown = 1<<0;
24        #[doc(alias = "UIControlEventTouchDownRepeat")]
25        const TouchDownRepeat = 1<<1;
26        #[doc(alias = "UIControlEventTouchDragInside")]
27        const TouchDragInside = 1<<2;
28        #[doc(alias = "UIControlEventTouchDragOutside")]
29        const TouchDragOutside = 1<<3;
30        #[doc(alias = "UIControlEventTouchDragEnter")]
31        const TouchDragEnter = 1<<4;
32        #[doc(alias = "UIControlEventTouchDragExit")]
33        const TouchDragExit = 1<<5;
34        #[doc(alias = "UIControlEventTouchUpInside")]
35        const TouchUpInside = 1<<6;
36        #[doc(alias = "UIControlEventTouchUpOutside")]
37        const TouchUpOutside = 1<<7;
38        #[doc(alias = "UIControlEventTouchCancel")]
39        const TouchCancel = 1<<8;
40        #[doc(alias = "UIControlEventValueChanged")]
41        const ValueChanged = 1<<12;
42        #[doc(alias = "UIControlEventPrimaryActionTriggered")]
43        const PrimaryActionTriggered = 1<<13;
44        #[doc(alias = "UIControlEventMenuActionTriggered")]
45        const MenuActionTriggered = 1<<14;
46        #[doc(alias = "UIControlEventEditingDidBegin")]
47        const EditingDidBegin = 1<<16;
48        #[doc(alias = "UIControlEventEditingChanged")]
49        const EditingChanged = 1<<17;
50        #[doc(alias = "UIControlEventEditingDidEnd")]
51        const EditingDidEnd = 1<<18;
52        #[doc(alias = "UIControlEventEditingDidEndOnExit")]
53        const EditingDidEndOnExit = 1<<19;
54        #[doc(alias = "UIControlEventAllTouchEvents")]
55        const AllTouchEvents = 0x00000FFF;
56        #[doc(alias = "UIControlEventAllEditingEvents")]
57        const AllEditingEvents = 0x000F0000;
58        #[doc(alias = "UIControlEventApplicationReserved")]
59        const ApplicationReserved = 0x0F000000;
60        #[doc(alias = "UIControlEventSystemReserved")]
61        const SystemReserved = 0xF0000000;
62        #[doc(alias = "UIControlEventAllEvents")]
63        const AllEvents = 0xFFFFFFFF;
64    }
65}
66
67unsafe impl Encode for UIControlEvents {
68    const ENCODING: Encoding = NSUInteger::ENCODING;
69}
70
71unsafe impl RefEncode for UIControlEvents {
72    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
73}
74
75/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontrolcontentverticalalignment?language=objc)
76// NS_ENUM
77#[repr(transparent)]
78#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
79pub struct UIControlContentVerticalAlignment(pub NSInteger);
80impl UIControlContentVerticalAlignment {
81    #[doc(alias = "UIControlContentVerticalAlignmentCenter")]
82    pub const Center: Self = Self(0);
83    #[doc(alias = "UIControlContentVerticalAlignmentTop")]
84    pub const Top: Self = Self(1);
85    #[doc(alias = "UIControlContentVerticalAlignmentBottom")]
86    pub const Bottom: Self = Self(2);
87    #[doc(alias = "UIControlContentVerticalAlignmentFill")]
88    pub const Fill: Self = Self(3);
89}
90
91unsafe impl Encode for UIControlContentVerticalAlignment {
92    const ENCODING: Encoding = NSInteger::ENCODING;
93}
94
95unsafe impl RefEncode for UIControlContentVerticalAlignment {
96    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
97}
98
99/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontrolcontenthorizontalalignment?language=objc)
100// NS_ENUM
101#[repr(transparent)]
102#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
103pub struct UIControlContentHorizontalAlignment(pub NSInteger);
104impl UIControlContentHorizontalAlignment {
105    #[doc(alias = "UIControlContentHorizontalAlignmentCenter")]
106    pub const Center: Self = Self(0);
107    #[doc(alias = "UIControlContentHorizontalAlignmentLeft")]
108    pub const Left: Self = Self(1);
109    #[doc(alias = "UIControlContentHorizontalAlignmentRight")]
110    pub const Right: Self = Self(2);
111    #[doc(alias = "UIControlContentHorizontalAlignmentFill")]
112    pub const Fill: Self = Self(3);
113    #[doc(alias = "UIControlContentHorizontalAlignmentLeading")]
114    pub const Leading: Self = Self(4);
115    #[doc(alias = "UIControlContentHorizontalAlignmentTrailing")]
116    pub const Trailing: Self = Self(5);
117}
118
119unsafe impl Encode for UIControlContentHorizontalAlignment {
120    const ENCODING: Encoding = NSInteger::ENCODING;
121}
122
123unsafe impl RefEncode for UIControlContentHorizontalAlignment {
124    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
125}
126
127/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontrolstate?language=objc)
128// NS_OPTIONS
129#[repr(transparent)]
130#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
131pub struct UIControlState(pub NSUInteger);
132bitflags::bitflags! {
133    impl UIControlState: NSUInteger {
134        #[doc(alias = "UIControlStateNormal")]
135        const Normal = 0;
136        #[doc(alias = "UIControlStateHighlighted")]
137        const Highlighted = 1<<0;
138        #[doc(alias = "UIControlStateDisabled")]
139        const Disabled = 1<<1;
140        #[doc(alias = "UIControlStateSelected")]
141        const Selected = 1<<2;
142        #[doc(alias = "UIControlStateFocused")]
143        const Focused = 1<<3;
144        #[doc(alias = "UIControlStateApplication")]
145        const Application = 0x00FF0000;
146        #[doc(alias = "UIControlStateReserved")]
147        const Reserved = 0xFF000000;
148    }
149}
150
151unsafe impl Encode for UIControlState {
152    const ENCODING: Encoding = NSUInteger::ENCODING;
153}
154
155unsafe impl RefEncode for UIControlState {
156    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
157}
158
159extern_class!(
160    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontrol?language=objc)
161    #[unsafe(super(UIView, UIResponder, NSObject))]
162    #[thread_kind = MainThreadOnly]
163    #[derive(Debug, PartialEq, Eq, Hash)]
164    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
165    pub struct UIControl;
166);
167
168#[cfg(all(
169    feature = "UIResponder",
170    feature = "UIView",
171    feature = "objc2-quartz-core"
172))]
173#[cfg(not(target_os = "watchos"))]
174extern_conformance!(
175    unsafe impl CALayerDelegate for UIControl {}
176);
177
178#[cfg(all(feature = "UIResponder", feature = "UIView"))]
179extern_conformance!(
180    unsafe impl NSCoding for UIControl {}
181);
182
183#[cfg(all(feature = "UIResponder", feature = "UIView"))]
184extern_conformance!(
185    unsafe impl NSObjectProtocol for UIControl {}
186);
187
188#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
189extern_conformance!(
190    unsafe impl UIAppearance for UIControl {}
191);
192
193#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
194extern_conformance!(
195    unsafe impl UIAppearanceContainer for UIControl {}
196);
197
198#[cfg(all(feature = "UIResponder", feature = "UIView"))]
199extern_conformance!(
200    unsafe impl UICoordinateSpace for UIControl {}
201);
202
203#[cfg(all(
204    feature = "UIDynamicBehavior",
205    feature = "UIResponder",
206    feature = "UIView"
207))]
208extern_conformance!(
209    unsafe impl UIDynamicItem for UIControl {}
210);
211
212#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
213extern_conformance!(
214    unsafe impl UIFocusEnvironment for UIControl {}
215);
216
217#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
218extern_conformance!(
219    unsafe impl UIFocusItem for UIControl {}
220);
221
222#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
223extern_conformance!(
224    unsafe impl UIFocusItemContainer for UIControl {}
225);
226
227#[cfg(all(feature = "UIResponder", feature = "UIView"))]
228extern_conformance!(
229    unsafe impl UIResponderStandardEditActions for UIControl {}
230);
231
232#[cfg(all(
233    feature = "UIResponder",
234    feature = "UITraitCollection",
235    feature = "UIView"
236))]
237extern_conformance!(
238    unsafe impl UITraitEnvironment for UIControl {}
239);
240
241#[cfg(all(feature = "UIResponder", feature = "UIView"))]
242impl UIControl {
243    extern_methods!(
244        #[cfg(feature = "objc2-core-foundation")]
245        #[unsafe(method(initWithFrame:))]
246        #[unsafe(method_family = init)]
247        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
248
249        #[unsafe(method(initWithCoder:))]
250        #[unsafe(method_family = init)]
251        pub unsafe fn initWithCoder(
252            this: Allocated<Self>,
253            coder: &NSCoder,
254        ) -> Option<Retained<Self>>;
255
256        #[cfg(all(
257            feature = "UIAction",
258            feature = "UIMenuElement",
259            feature = "objc2-core-foundation"
260        ))]
261        /// Initializes the control and adds primaryAction for the UIControlEventPrimaryActionTriggered control event. Subclasses of UIControl may alter or add behaviors around the usage of primaryAction, see subclass documentation of this initializer for additional information.
262        #[unsafe(method(initWithFrame:primaryAction:))]
263        #[unsafe(method_family = init)]
264        pub unsafe fn initWithFrame_primaryAction(
265            this: Allocated<Self>,
266            frame: CGRect,
267            primary_action: Option<&UIAction>,
268        ) -> Retained<Self>;
269
270        #[unsafe(method(isEnabled))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn isEnabled(&self) -> bool;
273
274        /// Setter for [`isEnabled`][Self::isEnabled].
275        #[unsafe(method(setEnabled:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn setEnabled(&self, enabled: bool);
278
279        #[unsafe(method(isSelected))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn isSelected(&self) -> bool;
282
283        /// Setter for [`isSelected`][Self::isSelected].
284        #[unsafe(method(setSelected:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn setSelected(&self, selected: bool);
287
288        #[unsafe(method(isHighlighted))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn isHighlighted(&self) -> bool;
291
292        /// Setter for [`isHighlighted`][Self::isHighlighted].
293        #[unsafe(method(setHighlighted:))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn setHighlighted(&self, highlighted: bool);
296
297        #[unsafe(method(contentVerticalAlignment))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn contentVerticalAlignment(&self) -> UIControlContentVerticalAlignment;
300
301        /// Setter for [`contentVerticalAlignment`][Self::contentVerticalAlignment].
302        #[unsafe(method(setContentVerticalAlignment:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn setContentVerticalAlignment(
305            &self,
306            content_vertical_alignment: UIControlContentVerticalAlignment,
307        );
308
309        #[unsafe(method(contentHorizontalAlignment))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn contentHorizontalAlignment(&self) -> UIControlContentHorizontalAlignment;
312
313        /// Setter for [`contentHorizontalAlignment`][Self::contentHorizontalAlignment].
314        #[unsafe(method(setContentHorizontalAlignment:))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn setContentHorizontalAlignment(
317            &self,
318            content_horizontal_alignment: UIControlContentHorizontalAlignment,
319        );
320
321        #[unsafe(method(effectiveContentHorizontalAlignment))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn effectiveContentHorizontalAlignment(
324            &self,
325        ) -> UIControlContentHorizontalAlignment;
326
327        #[unsafe(method(state))]
328        #[unsafe(method_family = none)]
329        pub unsafe fn state(&self) -> UIControlState;
330
331        #[unsafe(method(isTracking))]
332        #[unsafe(method_family = none)]
333        pub unsafe fn isTracking(&self) -> bool;
334
335        #[unsafe(method(isTouchInside))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn isTouchInside(&self) -> bool;
338
339        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
340        #[unsafe(method(beginTrackingWithTouch:withEvent:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn beginTrackingWithTouch_withEvent(
343            &self,
344            touch: &UITouch,
345            event: Option<&UIEvent>,
346        ) -> bool;
347
348        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
349        #[unsafe(method(continueTrackingWithTouch:withEvent:))]
350        #[unsafe(method_family = none)]
351        pub unsafe fn continueTrackingWithTouch_withEvent(
352            &self,
353            touch: &UITouch,
354            event: Option<&UIEvent>,
355        ) -> bool;
356
357        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
358        #[unsafe(method(endTrackingWithTouch:withEvent:))]
359        #[unsafe(method_family = none)]
360        pub unsafe fn endTrackingWithTouch_withEvent(
361            &self,
362            touch: Option<&UITouch>,
363            event: Option<&UIEvent>,
364        );
365
366        #[cfg(feature = "UIEvent")]
367        #[unsafe(method(cancelTrackingWithEvent:))]
368        #[unsafe(method_family = none)]
369        pub unsafe fn cancelTrackingWithEvent(&self, event: Option<&UIEvent>);
370
371        #[unsafe(method(addTarget:action:forControlEvents:))]
372        #[unsafe(method_family = none)]
373        pub unsafe fn addTarget_action_forControlEvents(
374            &self,
375            target: Option<&AnyObject>,
376            action: Sel,
377            control_events: UIControlEvents,
378        );
379
380        #[unsafe(method(removeTarget:action:forControlEvents:))]
381        #[unsafe(method_family = none)]
382        pub unsafe fn removeTarget_action_forControlEvents(
383            &self,
384            target: Option<&AnyObject>,
385            action: Option<Sel>,
386            control_events: UIControlEvents,
387        );
388
389        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
390        /// Adds the UIAction to a given event. UIActions are uniqued based on their identifier, and subsequent actions with the same identifier replace previously added actions. You may add multiple UIActions for corresponding controlEvents, and you may add the same action to multiple controlEvents.
391        #[unsafe(method(addAction:forControlEvents:))]
392        #[unsafe(method_family = none)]
393        pub unsafe fn addAction_forControlEvents(
394            &self,
395            action: &UIAction,
396            control_events: UIControlEvents,
397        );
398
399        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
400        /// Removes the action from the set of passed control events.
401        #[unsafe(method(removeAction:forControlEvents:))]
402        #[unsafe(method_family = none)]
403        pub unsafe fn removeAction_forControlEvents(
404            &self,
405            action: &UIAction,
406            control_events: UIControlEvents,
407        );
408
409        #[cfg(feature = "UIAction")]
410        /// Removes the action with the provided identifier from the set of passed control events.
411        #[unsafe(method(removeActionForIdentifier:forControlEvents:))]
412        #[unsafe(method_family = none)]
413        pub unsafe fn removeActionForIdentifier_forControlEvents(
414            &self,
415            action_identifier: &UIActionIdentifier,
416            control_events: UIControlEvents,
417        );
418
419        /// Performs the control's primary action.
420        #[unsafe(method(performPrimaryAction))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn performPrimaryAction(&self);
423
424        #[unsafe(method(allTargets))]
425        #[unsafe(method_family = none)]
426        pub unsafe fn allTargets(&self) -> Retained<NSSet>;
427
428        #[unsafe(method(allControlEvents))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn allControlEvents(&self) -> UIControlEvents;
431
432        #[unsafe(method(actionsForTarget:forControlEvent:))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn actionsForTarget_forControlEvent(
435            &self,
436            target: Option<&AnyObject>,
437            control_event: UIControlEvents,
438        ) -> Option<Retained<NSArray<NSString>>>;
439
440        #[cfg(all(feature = "UIAction", feature = "UIMenuElement", feature = "block2"))]
441        /// Iterate over the event handlers installed on this control at the time this method is called. For each call, either actionHandler or action will be non-nil. controlEvents is always non-zero. Setting *stop to YES will terminate the enumeration early. It is legal to manipulate the control's event handlers within the block.
442        #[unsafe(method(enumerateEventHandlers:))]
443        #[unsafe(method_family = none)]
444        pub unsafe fn enumerateEventHandlers(
445            &self,
446            iterator: &block2::DynBlock<
447                dyn Fn(*mut UIAction, *mut AnyObject, Option<Sel>, UIControlEvents, NonNull<Bool>)
448                    + '_,
449            >,
450        );
451
452        #[cfg(feature = "UIEvent")]
453        /// Dispatch the target-action pair. This method is called repeatedly by -sendActionsForControlEvents: and is a point at which you can observe or override behavior.
454        #[unsafe(method(sendAction:to:forEvent:))]
455        #[unsafe(method_family = none)]
456        pub unsafe fn sendAction_to_forEvent(
457            &self,
458            action: Sel,
459            target: Option<&AnyObject>,
460            event: Option<&UIEvent>,
461        );
462
463        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
464        /// Like -sendAction:to:forEvent:, this method is called by -sendActionsForControlEvents:. You may override this method to observe or modify behavior. If you override this method, you should call super precisely once to dispatch the action, or not call super to suppress sending that action.
465        #[unsafe(method(sendAction:))]
466        #[unsafe(method_family = none)]
467        pub unsafe fn sendAction(&self, action: &UIAction);
468
469        /// send all actions associated with the given control events
470        #[unsafe(method(sendActionsForControlEvents:))]
471        #[unsafe(method_family = none)]
472        pub unsafe fn sendActionsForControlEvents(&self, control_events: UIControlEvents);
473
474        #[cfg(feature = "UIContextMenuInteraction")]
475        /// Returns a UIContextMenuInteraction with this control set as its delegate. Before constructing the UIContextMenuInteraction, UIControl verifies 'self' is a viable delegate. See 'Implementing UIControl Menus' below for more details.
476        #[unsafe(method(contextMenuInteraction))]
477        #[unsafe(method_family = none)]
478        pub unsafe fn contextMenuInteraction(&self) -> Option<Retained<UIContextMenuInteraction>>;
479
480        /// Specifies if the context menu interaction is enabled. NO by default.
481        #[unsafe(method(isContextMenuInteractionEnabled))]
482        #[unsafe(method_family = none)]
483        pub unsafe fn isContextMenuInteractionEnabled(&self) -> bool;
484
485        /// Setter for [`isContextMenuInteractionEnabled`][Self::isContextMenuInteractionEnabled].
486        #[unsafe(method(setContextMenuInteractionEnabled:))]
487        #[unsafe(method_family = none)]
488        pub unsafe fn setContextMenuInteractionEnabled(
489            &self,
490            context_menu_interaction_enabled: bool,
491        );
492
493        /// If the contextMenuInteraction is the primary action of the control, invoked on touch-down. NO by default.
494        #[unsafe(method(showsMenuAsPrimaryAction))]
495        #[unsafe(method_family = none)]
496        pub unsafe fn showsMenuAsPrimaryAction(&self) -> bool;
497
498        /// Setter for [`showsMenuAsPrimaryAction`][Self::showsMenuAsPrimaryAction].
499        #[unsafe(method(setShowsMenuAsPrimaryAction:))]
500        #[unsafe(method_family = none)]
501        pub unsafe fn setShowsMenuAsPrimaryAction(&self, shows_menu_as_primary_action: bool);
502
503        #[cfg(all(
504            feature = "UIContextMenuConfiguration",
505            feature = "objc2-core-foundation"
506        ))]
507        /// Return a point in this control's coordinate space to which to attach the given configuration's menu.
508        #[unsafe(method(menuAttachmentPointForConfiguration:))]
509        #[unsafe(method_family = none)]
510        pub unsafe fn menuAttachmentPointForConfiguration(
511            &self,
512            configuration: &UIContextMenuConfiguration,
513        ) -> CGPoint;
514
515        /// Assigning a value to this property causes the tool tip to be displayed for the view. Setting the property to nil cancels the display of the tool tip for the view.
516        #[unsafe(method(toolTip))]
517        #[unsafe(method_family = none)]
518        pub unsafe fn toolTip(&self) -> Option<Retained<NSString>>;
519
520        /// Setter for [`toolTip`][Self::toolTip].
521        #[unsafe(method(setToolTip:))]
522        #[unsafe(method_family = none)]
523        pub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>);
524
525        #[cfg(feature = "UIToolTipInteraction")]
526        /// Returns the control's default UIToolTipInteraction.
527        #[unsafe(method(toolTipInteraction))]
528        #[unsafe(method_family = none)]
529        pub unsafe fn toolTipInteraction(&self) -> Option<Retained<UIToolTipInteraction>>;
530
531        /// Whether or not symbol animations are enabled for this control.
532        /// The default value varies depending on the control.
533        #[unsafe(method(isSymbolAnimationEnabled))]
534        #[unsafe(method_family = none)]
535        pub unsafe fn isSymbolAnimationEnabled(&self) -> bool;
536
537        /// Setter for [`isSymbolAnimationEnabled`][Self::isSymbolAnimationEnabled].
538        #[unsafe(method(setSymbolAnimationEnabled:))]
539        #[unsafe(method_family = none)]
540        pub unsafe fn setSymbolAnimationEnabled(&self, symbol_animation_enabled: bool);
541    );
542}
543
544/// Methods declared on superclass `NSObject`.
545#[cfg(all(feature = "UIResponder", feature = "UIView"))]
546impl UIControl {
547    extern_methods!(
548        #[unsafe(method(init))]
549        #[unsafe(method_family = init)]
550        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
551
552        #[unsafe(method(new))]
553        #[unsafe(method_family = new)]
554        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
555    );
556}
557
558/// Implementing UIControl Menus
559/// UIControl will only create a UIContextMenuInteraction if you've created a subclass of UIControl with a minimum viable delegate implementation. UIControl extends the contract of UIContextMenuInteractionDelegate for these methods, see each method for more detail.
560#[cfg(all(feature = "UIResponder", feature = "UIView"))]
561impl UIControl {
562    extern_methods!(
563        #[cfg(all(
564            feature = "UIContextMenuConfiguration",
565            feature = "UIContextMenuInteraction",
566            feature = "objc2-core-foundation"
567        ))]
568        /// An override is required for UIControl to create a UIContextMenuInteraction. Direct UIControl subclasses do not need to call super.
569        #[unsafe(method(contextMenuInteraction:configurationForMenuAtLocation:))]
570        #[unsafe(method_family = none)]
571        pub unsafe fn contextMenuInteraction_configurationForMenuAtLocation(
572            &self,
573            interaction: &UIContextMenuInteraction,
574            location: CGPoint,
575        ) -> Option<Retained<UIContextMenuConfiguration>>;
576
577        #[cfg(all(
578            feature = "UIContextMenuConfiguration",
579            feature = "UIContextMenuInteraction",
580            feature = "UITargetedPreview"
581        ))]
582        /// Direct UIControl subclasses do not need to call super.
583        #[unsafe(method(contextMenuInteraction:previewForHighlightingMenuWithConfiguration:))]
584        #[unsafe(method_family = none)]
585        pub unsafe fn contextMenuInteraction_previewForHighlightingMenuWithConfiguration(
586            &self,
587            interaction: &UIContextMenuInteraction,
588            configuration: &UIContextMenuConfiguration,
589        ) -> Option<Retained<UITargetedPreview>>;
590
591        #[cfg(all(
592            feature = "UIContextMenuConfiguration",
593            feature = "UIContextMenuInteraction",
594            feature = "UITargetedPreview"
595        ))]
596        /// Direct UIControl subclasses do not need to call super.
597        #[unsafe(method(contextMenuInteraction:previewForDismissingMenuWithConfiguration:))]
598        #[unsafe(method_family = none)]
599        pub unsafe fn contextMenuInteraction_previewForDismissingMenuWithConfiguration(
600            &self,
601            interaction: &UIContextMenuInteraction,
602            configuration: &UIContextMenuConfiguration,
603        ) -> Option<Retained<UITargetedPreview>>;
604
605        #[cfg(all(
606            feature = "UIContextMenuConfiguration",
607            feature = "UIContextMenuInteraction"
608        ))]
609        /// UIControl subclasses should always call super.
610        #[unsafe(method(contextMenuInteraction:willDisplayMenuForConfiguration:animator:))]
611        #[unsafe(method_family = none)]
612        pub unsafe fn contextMenuInteraction_willDisplayMenuForConfiguration_animator(
613            &self,
614            interaction: &UIContextMenuInteraction,
615            configuration: &UIContextMenuConfiguration,
616            animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
617        );
618
619        #[cfg(all(
620            feature = "UIContextMenuConfiguration",
621            feature = "UIContextMenuInteraction"
622        ))]
623        /// UIControl subclasses should always call super.
624        #[unsafe(method(contextMenuInteraction:willEndForConfiguration:animator:))]
625        #[unsafe(method_family = none)]
626        pub unsafe fn contextMenuInteraction_willEndForConfiguration_animator(
627            &self,
628            interaction: &UIContextMenuInteraction,
629            configuration: &UIContextMenuConfiguration,
630            animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
631        );
632
633        #[cfg(all(
634            feature = "UIContextMenuConfiguration",
635            feature = "UIContextMenuInteraction"
636        ))]
637        /// UIControl based menus do not display previews, so this method will not be called even if implemented. UIControl does not have an implementation.
638        #[unsafe(method(contextMenuInteraction:willPerformPreviewActionForMenuWithConfiguration:animator:))]
639        #[unsafe(method_family = none)]
640        pub unsafe fn contextMenuInteraction_willPerformPreviewActionForMenuWithConfiguration_animator(
641            &self,
642            interaction: &UIContextMenuInteraction,
643            configuration: &UIContextMenuConfiguration,
644            animator: &ProtocolObject<dyn UIContextMenuInteractionCommitAnimating>,
645        );
646    );
647}
648
649#[cfg(all(
650    feature = "UIContextMenuInteraction",
651    feature = "UIResponder",
652    feature = "UIView"
653))]
654extern_conformance!(
655    unsafe impl UIContextMenuInteractionDelegate for UIControl {}
656);