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"))]
174unsafe impl CALayerDelegate for UIControl {}
175
176#[cfg(all(feature = "UIResponder", feature = "UIView"))]
177unsafe impl NSCoding for UIControl {}
178
179#[cfg(all(feature = "UIResponder", feature = "UIView"))]
180unsafe impl NSObjectProtocol for UIControl {}
181
182#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
183unsafe impl UIAppearance for UIControl {}
184
185#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
186unsafe impl UIAppearanceContainer for UIControl {}
187
188#[cfg(all(feature = "UIResponder", feature = "UIView"))]
189unsafe impl UICoordinateSpace for UIControl {}
190
191#[cfg(all(
192    feature = "UIDynamicBehavior",
193    feature = "UIResponder",
194    feature = "UIView"
195))]
196unsafe impl UIDynamicItem for UIControl {}
197
198#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
199unsafe impl UIFocusEnvironment for UIControl {}
200
201#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
202unsafe impl UIFocusItem for UIControl {}
203
204#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
205unsafe impl UIFocusItemContainer for UIControl {}
206
207#[cfg(all(feature = "UIResponder", feature = "UIView"))]
208unsafe impl UIResponderStandardEditActions for UIControl {}
209
210#[cfg(all(
211    feature = "UIResponder",
212    feature = "UITraitCollection",
213    feature = "UIView"
214))]
215unsafe impl UITraitEnvironment for UIControl {}
216
217#[cfg(all(feature = "UIResponder", feature = "UIView"))]
218impl UIControl {
219    extern_methods!(
220        #[cfg(feature = "objc2-core-foundation")]
221        #[unsafe(method(initWithFrame:))]
222        #[unsafe(method_family = init)]
223        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
224
225        #[unsafe(method(initWithCoder:))]
226        #[unsafe(method_family = init)]
227        pub unsafe fn initWithCoder(
228            this: Allocated<Self>,
229            coder: &NSCoder,
230        ) -> Option<Retained<Self>>;
231
232        #[cfg(all(
233            feature = "UIAction",
234            feature = "UIMenuElement",
235            feature = "objc2-core-foundation"
236        ))]
237        /// 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.
238        #[unsafe(method(initWithFrame:primaryAction:))]
239        #[unsafe(method_family = init)]
240        pub unsafe fn initWithFrame_primaryAction(
241            this: Allocated<Self>,
242            frame: CGRect,
243            primary_action: Option<&UIAction>,
244        ) -> Retained<Self>;
245
246        #[unsafe(method(isEnabled))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn isEnabled(&self) -> bool;
249
250        /// Setter for [`isEnabled`][Self::isEnabled].
251        #[unsafe(method(setEnabled:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn setEnabled(&self, enabled: bool);
254
255        #[unsafe(method(isSelected))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn isSelected(&self) -> bool;
258
259        /// Setter for [`isSelected`][Self::isSelected].
260        #[unsafe(method(setSelected:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn setSelected(&self, selected: bool);
263
264        #[unsafe(method(isHighlighted))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn isHighlighted(&self) -> bool;
267
268        /// Setter for [`isHighlighted`][Self::isHighlighted].
269        #[unsafe(method(setHighlighted:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn setHighlighted(&self, highlighted: bool);
272
273        #[unsafe(method(contentVerticalAlignment))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn contentVerticalAlignment(&self) -> UIControlContentVerticalAlignment;
276
277        /// Setter for [`contentVerticalAlignment`][Self::contentVerticalAlignment].
278        #[unsafe(method(setContentVerticalAlignment:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn setContentVerticalAlignment(
281            &self,
282            content_vertical_alignment: UIControlContentVerticalAlignment,
283        );
284
285        #[unsafe(method(contentHorizontalAlignment))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn contentHorizontalAlignment(&self) -> UIControlContentHorizontalAlignment;
288
289        /// Setter for [`contentHorizontalAlignment`][Self::contentHorizontalAlignment].
290        #[unsafe(method(setContentHorizontalAlignment:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn setContentHorizontalAlignment(
293            &self,
294            content_horizontal_alignment: UIControlContentHorizontalAlignment,
295        );
296
297        #[unsafe(method(effectiveContentHorizontalAlignment))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn effectiveContentHorizontalAlignment(
300            &self,
301        ) -> UIControlContentHorizontalAlignment;
302
303        #[unsafe(method(state))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn state(&self) -> UIControlState;
306
307        #[unsafe(method(isTracking))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn isTracking(&self) -> bool;
310
311        #[unsafe(method(isTouchInside))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn isTouchInside(&self) -> bool;
314
315        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
316        #[unsafe(method(beginTrackingWithTouch:withEvent:))]
317        #[unsafe(method_family = none)]
318        pub unsafe fn beginTrackingWithTouch_withEvent(
319            &self,
320            touch: &UITouch,
321            event: Option<&UIEvent>,
322        ) -> bool;
323
324        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
325        #[unsafe(method(continueTrackingWithTouch:withEvent:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn continueTrackingWithTouch_withEvent(
328            &self,
329            touch: &UITouch,
330            event: Option<&UIEvent>,
331        ) -> bool;
332
333        #[cfg(all(feature = "UIEvent", feature = "UITouch"))]
334        #[unsafe(method(endTrackingWithTouch:withEvent:))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn endTrackingWithTouch_withEvent(
337            &self,
338            touch: Option<&UITouch>,
339            event: Option<&UIEvent>,
340        );
341
342        #[cfg(feature = "UIEvent")]
343        #[unsafe(method(cancelTrackingWithEvent:))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn cancelTrackingWithEvent(&self, event: Option<&UIEvent>);
346
347        #[unsafe(method(addTarget:action:forControlEvents:))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn addTarget_action_forControlEvents(
350            &self,
351            target: Option<&AnyObject>,
352            action: Sel,
353            control_events: UIControlEvents,
354        );
355
356        #[unsafe(method(removeTarget:action:forControlEvents:))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn removeTarget_action_forControlEvents(
359            &self,
360            target: Option<&AnyObject>,
361            action: Option<Sel>,
362            control_events: UIControlEvents,
363        );
364
365        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
366        /// 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.
367        #[unsafe(method(addAction:forControlEvents:))]
368        #[unsafe(method_family = none)]
369        pub unsafe fn addAction_forControlEvents(
370            &self,
371            action: &UIAction,
372            control_events: UIControlEvents,
373        );
374
375        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
376        /// Removes the action from the set of passed control events.
377        #[unsafe(method(removeAction:forControlEvents:))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn removeAction_forControlEvents(
380            &self,
381            action: &UIAction,
382            control_events: UIControlEvents,
383        );
384
385        #[cfg(feature = "UIAction")]
386        /// Removes the action with the provided identifier from the set of passed control events.
387        #[unsafe(method(removeActionForIdentifier:forControlEvents:))]
388        #[unsafe(method_family = none)]
389        pub unsafe fn removeActionForIdentifier_forControlEvents(
390            &self,
391            action_identifier: &UIActionIdentifier,
392            control_events: UIControlEvents,
393        );
394
395        /// Performs the control's primary action.
396        #[unsafe(method(performPrimaryAction))]
397        #[unsafe(method_family = none)]
398        pub unsafe fn performPrimaryAction(&self);
399
400        #[unsafe(method(allTargets))]
401        #[unsafe(method_family = none)]
402        pub unsafe fn allTargets(&self) -> Retained<NSSet>;
403
404        #[unsafe(method(allControlEvents))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn allControlEvents(&self) -> UIControlEvents;
407
408        #[unsafe(method(actionsForTarget:forControlEvent:))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn actionsForTarget_forControlEvent(
411            &self,
412            target: Option<&AnyObject>,
413            control_event: UIControlEvents,
414        ) -> Option<Retained<NSArray<NSString>>>;
415
416        #[cfg(all(feature = "UIAction", feature = "UIMenuElement", feature = "block2"))]
417        /// 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.
418        #[unsafe(method(enumerateEventHandlers:))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn enumerateEventHandlers(
421            &self,
422            iterator: &block2::Block<
423                dyn Fn(*mut UIAction, *mut AnyObject, Option<Sel>, UIControlEvents, NonNull<Bool>)
424                    + '_,
425            >,
426        );
427
428        #[cfg(feature = "UIEvent")]
429        /// Dispatch the target-action pair. This method is called repeatedly by -sendActionsForControlEvents: and is a point at which you can observe or override behavior.
430        #[unsafe(method(sendAction:to:forEvent:))]
431        #[unsafe(method_family = none)]
432        pub unsafe fn sendAction_to_forEvent(
433            &self,
434            action: Sel,
435            target: Option<&AnyObject>,
436            event: Option<&UIEvent>,
437        );
438
439        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
440        /// 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.
441        #[unsafe(method(sendAction:))]
442        #[unsafe(method_family = none)]
443        pub unsafe fn sendAction(&self, action: &UIAction);
444
445        /// send all actions associated with the given control events
446        #[unsafe(method(sendActionsForControlEvents:))]
447        #[unsafe(method_family = none)]
448        pub unsafe fn sendActionsForControlEvents(&self, control_events: UIControlEvents);
449
450        #[cfg(feature = "UIContextMenuInteraction")]
451        /// 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.
452        #[unsafe(method(contextMenuInteraction))]
453        #[unsafe(method_family = none)]
454        pub unsafe fn contextMenuInteraction(&self) -> Option<Retained<UIContextMenuInteraction>>;
455
456        /// Specifies if the context menu interaction is enabled. NO by default.
457        #[unsafe(method(isContextMenuInteractionEnabled))]
458        #[unsafe(method_family = none)]
459        pub unsafe fn isContextMenuInteractionEnabled(&self) -> bool;
460
461        /// Setter for [`isContextMenuInteractionEnabled`][Self::isContextMenuInteractionEnabled].
462        #[unsafe(method(setContextMenuInteractionEnabled:))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn setContextMenuInteractionEnabled(
465            &self,
466            context_menu_interaction_enabled: bool,
467        );
468
469        /// If the contextMenuInteraction is the primary action of the control, invoked on touch-down. NO by default.
470        #[unsafe(method(showsMenuAsPrimaryAction))]
471        #[unsafe(method_family = none)]
472        pub unsafe fn showsMenuAsPrimaryAction(&self) -> bool;
473
474        /// Setter for [`showsMenuAsPrimaryAction`][Self::showsMenuAsPrimaryAction].
475        #[unsafe(method(setShowsMenuAsPrimaryAction:))]
476        #[unsafe(method_family = none)]
477        pub unsafe fn setShowsMenuAsPrimaryAction(&self, shows_menu_as_primary_action: bool);
478
479        #[cfg(all(
480            feature = "UIContextMenuConfiguration",
481            feature = "objc2-core-foundation"
482        ))]
483        /// Return a point in this control's coordinate space to which to attach the given configuration's menu.
484        #[unsafe(method(menuAttachmentPointForConfiguration:))]
485        #[unsafe(method_family = none)]
486        pub unsafe fn menuAttachmentPointForConfiguration(
487            &self,
488            configuration: &UIContextMenuConfiguration,
489        ) -> CGPoint;
490
491        /// 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.
492        #[unsafe(method(toolTip))]
493        #[unsafe(method_family = none)]
494        pub unsafe fn toolTip(&self) -> Option<Retained<NSString>>;
495
496        /// Setter for [`toolTip`][Self::toolTip].
497        #[unsafe(method(setToolTip:))]
498        #[unsafe(method_family = none)]
499        pub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>);
500
501        #[cfg(feature = "UIToolTipInteraction")]
502        /// Returns the control's default UIToolTipInteraction.
503        #[unsafe(method(toolTipInteraction))]
504        #[unsafe(method_family = none)]
505        pub unsafe fn toolTipInteraction(&self) -> Option<Retained<UIToolTipInteraction>>;
506
507        /// Whether or not symbol animations are enabled for this control.
508        /// The default value varies depending on the control.
509        #[unsafe(method(isSymbolAnimationEnabled))]
510        #[unsafe(method_family = none)]
511        pub unsafe fn isSymbolAnimationEnabled(&self) -> bool;
512
513        /// Setter for [`isSymbolAnimationEnabled`][Self::isSymbolAnimationEnabled].
514        #[unsafe(method(setSymbolAnimationEnabled:))]
515        #[unsafe(method_family = none)]
516        pub unsafe fn setSymbolAnimationEnabled(&self, symbol_animation_enabled: bool);
517    );
518}
519
520/// Methods declared on superclass `NSObject`.
521#[cfg(all(feature = "UIResponder", feature = "UIView"))]
522impl UIControl {
523    extern_methods!(
524        #[unsafe(method(init))]
525        #[unsafe(method_family = init)]
526        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
527
528        #[unsafe(method(new))]
529        #[unsafe(method_family = new)]
530        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
531    );
532}
533
534/// Implementing UIControl Menus
535/// 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.
536#[cfg(all(feature = "UIResponder", feature = "UIView"))]
537impl UIControl {
538    extern_methods!(
539        #[cfg(all(
540            feature = "UIContextMenuConfiguration",
541            feature = "UIContextMenuInteraction",
542            feature = "objc2-core-foundation"
543        ))]
544        /// An override is required for UIControl to create a UIContextMenuInteraction. Direct UIControl subclasses do not need to call super.
545        #[unsafe(method(contextMenuInteraction:configurationForMenuAtLocation:))]
546        #[unsafe(method_family = none)]
547        pub unsafe fn contextMenuInteraction_configurationForMenuAtLocation(
548            &self,
549            interaction: &UIContextMenuInteraction,
550            location: CGPoint,
551        ) -> Option<Retained<UIContextMenuConfiguration>>;
552
553        #[cfg(all(
554            feature = "UIContextMenuConfiguration",
555            feature = "UIContextMenuInteraction",
556            feature = "UITargetedPreview"
557        ))]
558        /// Direct UIControl subclasses do not need to call super.
559        #[unsafe(method(contextMenuInteraction:previewForHighlightingMenuWithConfiguration:))]
560        #[unsafe(method_family = none)]
561        pub unsafe fn contextMenuInteraction_previewForHighlightingMenuWithConfiguration(
562            &self,
563            interaction: &UIContextMenuInteraction,
564            configuration: &UIContextMenuConfiguration,
565        ) -> Option<Retained<UITargetedPreview>>;
566
567        #[cfg(all(
568            feature = "UIContextMenuConfiguration",
569            feature = "UIContextMenuInteraction",
570            feature = "UITargetedPreview"
571        ))]
572        /// Direct UIControl subclasses do not need to call super.
573        #[unsafe(method(contextMenuInteraction:previewForDismissingMenuWithConfiguration:))]
574        #[unsafe(method_family = none)]
575        pub unsafe fn contextMenuInteraction_previewForDismissingMenuWithConfiguration(
576            &self,
577            interaction: &UIContextMenuInteraction,
578            configuration: &UIContextMenuConfiguration,
579        ) -> Option<Retained<UITargetedPreview>>;
580
581        #[cfg(all(
582            feature = "UIContextMenuConfiguration",
583            feature = "UIContextMenuInteraction"
584        ))]
585        /// UIControl subclasses should always call super.
586        #[unsafe(method(contextMenuInteraction:willDisplayMenuForConfiguration:animator:))]
587        #[unsafe(method_family = none)]
588        pub unsafe fn contextMenuInteraction_willDisplayMenuForConfiguration_animator(
589            &self,
590            interaction: &UIContextMenuInteraction,
591            configuration: &UIContextMenuConfiguration,
592            animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
593        );
594
595        #[cfg(all(
596            feature = "UIContextMenuConfiguration",
597            feature = "UIContextMenuInteraction"
598        ))]
599        /// UIControl subclasses should always call super.
600        #[unsafe(method(contextMenuInteraction:willEndForConfiguration:animator:))]
601        #[unsafe(method_family = none)]
602        pub unsafe fn contextMenuInteraction_willEndForConfiguration_animator(
603            &self,
604            interaction: &UIContextMenuInteraction,
605            configuration: &UIContextMenuConfiguration,
606            animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
607        );
608
609        #[cfg(all(
610            feature = "UIContextMenuConfiguration",
611            feature = "UIContextMenuInteraction"
612        ))]
613        /// UIControl based menus do not display previews, so this method will not be called even if implemented. UIControl does not have an implementation.
614        #[unsafe(method(contextMenuInteraction:willPerformPreviewActionForMenuWithConfiguration:animator:))]
615        #[unsafe(method_family = none)]
616        pub unsafe fn contextMenuInteraction_willPerformPreviewActionForMenuWithConfiguration_animator(
617            &self,
618            interaction: &UIContextMenuInteraction,
619            configuration: &UIContextMenuConfiguration,
620            animator: &ProtocolObject<dyn UIContextMenuInteractionCommitAnimating>,
621        );
622    );
623}
624
625#[cfg(all(
626    feature = "UIContextMenuInteraction",
627    feature = "UIResponder",
628    feature = "UIView"
629))]
630unsafe impl UIContextMenuInteractionDelegate for UIControl {}