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