objc2_ui_kit/generated/
UIAction.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/uiactionidentifier?language=objc)
11// NS_TYPED_EXTENSIBLE_ENUM
12pub type UIActionIdentifier = NSString;
13
14extern "C" {
15    /// Default action identifiers for paste variants
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiactionpaste?language=objc)
18    pub static UIActionPaste: &'static UIActionIdentifier;
19}
20
21extern "C" {
22    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiactionpasteandmatchstyle?language=objc)
23    pub static UIActionPasteAndMatchStyle: &'static UIActionIdentifier;
24}
25
26extern "C" {
27    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiactionpasteandgo?language=objc)
28    pub static UIActionPasteAndGo: &'static UIActionIdentifier;
29}
30
31extern "C" {
32    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiactionpasteandsearch?language=objc)
33    pub static UIActionPasteAndSearch: &'static UIActionIdentifier;
34}
35
36/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiactionhandler?language=objc)
37#[cfg(all(feature = "UIMenuElement", feature = "block2"))]
38pub type UIActionHandler = *mut block2::DynBlock<dyn Fn(NonNull<UIAction>)>;
39
40extern_class!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiaction?language=objc)
42    #[unsafe(super(UIMenuElement, NSObject))]
43    #[thread_kind = MainThreadOnly]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    #[cfg(feature = "UIMenuElement")]
46    pub struct UIAction;
47);
48
49#[cfg(feature = "UIMenuElement")]
50extern_conformance!(
51    unsafe impl NSCoding for UIAction {}
52);
53
54#[cfg(feature = "UIMenuElement")]
55extern_conformance!(
56    unsafe impl NSCopying for UIAction {}
57);
58
59#[cfg(feature = "UIMenuElement")]
60unsafe impl CopyingHelper for UIAction {
61    type Result = Self;
62}
63
64#[cfg(feature = "UIMenuElement")]
65extern_conformance!(
66    unsafe impl NSObjectProtocol for UIAction {}
67);
68
69#[cfg(feature = "UIMenuElement")]
70extern_conformance!(
71    unsafe impl NSSecureCoding for UIAction {}
72);
73
74#[cfg(all(feature = "UIMenuElement", feature = "UIMenuLeaf"))]
75extern_conformance!(
76    unsafe impl UIMenuLeaf for UIAction {}
77);
78
79#[cfg(feature = "UIMenuElement")]
80impl UIAction {
81    extern_methods!(
82        /// Short display title.
83        #[unsafe(method(title))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn title(&self) -> Retained<NSString>;
86
87        /// Setter for [`title`][Self::title].
88        #[unsafe(method(setTitle:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn setTitle(&self, title: &NSString);
91
92        #[cfg(feature = "UIImage")]
93        /// Image that can appear next to this action.
94        #[unsafe(method(image))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
97
98        #[cfg(feature = "UIImage")]
99        /// Setter for [`image`][Self::image].
100        #[unsafe(method(setImage:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn setImage(&self, image: Option<&UIImage>);
103
104        /// Elaborated title used in keyboard shortcut overlay.
105        #[unsafe(method(discoverabilityTitle))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn discoverabilityTitle(&self) -> Option<Retained<NSString>>;
108
109        /// Setter for [`discoverabilityTitle`][Self::discoverabilityTitle].
110        #[unsafe(method(setDiscoverabilityTitle:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn setDiscoverabilityTitle(&self, discoverability_title: Option<&NSString>);
113
114        /// This action's identifier.
115        #[unsafe(method(identifier))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn identifier(&self) -> Retained<UIActionIdentifier>;
118
119        /// This action's style.
120        #[unsafe(method(attributes))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn attributes(&self) -> UIMenuElementAttributes;
123
124        /// Setter for [`attributes`][Self::attributes].
125        #[unsafe(method(setAttributes:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn setAttributes(&self, attributes: UIMenuElementAttributes);
128
129        /// State that can appear next to this action.
130        #[unsafe(method(state))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn state(&self) -> UIMenuElementState;
133
134        /// Setter for [`state`][Self::state].
135        #[unsafe(method(setState:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setState(&self, state: UIMenuElementState);
138
139        /// If available, the object on behalf of which the actionHandler is called.
140        #[unsafe(method(sender))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn sender(&self) -> Option<Retained<AnyObject>>;
143
144        #[cfg(feature = "block2")]
145        /// Creates a UIAction with an empty title, nil image, and automatically generated identifier
146        ///
147        ///
148        /// Parameter `handler`: Handler block. Called when the user selects the action.
149        ///
150        ///
151        /// Returns: A new UIAction.
152        #[unsafe(method(actionWithHandler:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn actionWithHandler(
155            handler: UIActionHandler,
156            mtm: MainThreadMarker,
157        ) -> Retained<Self>;
158
159        #[cfg(all(feature = "UIImage", feature = "block2"))]
160        /// Creates a UIAction with the given arguments.
161        ///
162        ///
163        /// Parameter `title`: The action's title.
164        ///
165        /// Parameter `image`: Image that can appear next to this action, if needed.
166        ///
167        /// Parameter `identifier`: The action's identifier. Pass nil to use an auto-generated identifier.
168        ///
169        /// Parameter `handler`: Handler block. Called when the user selects the action.
170        ///
171        ///
172        /// Returns: A new UIAction.
173        #[unsafe(method(actionWithTitle:image:identifier:handler:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn actionWithTitle_image_identifier_handler(
176            title: &NSString,
177            image: Option<&UIImage>,
178            identifier: Option<&UIActionIdentifier>,
179            handler: UIActionHandler,
180            mtm: MainThreadMarker,
181        ) -> Retained<Self>;
182
183        #[unsafe(method(init))]
184        #[unsafe(method_family = init)]
185        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
186
187        #[unsafe(method(new))]
188        #[unsafe(method_family = new)]
189        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
190    );
191}
192
193/// Methods declared on superclass `UIMenuElement`.
194#[cfg(feature = "UIMenuElement")]
195impl UIAction {
196    extern_methods!(
197        #[unsafe(method(initWithCoder:))]
198        #[unsafe(method_family = init)]
199        pub unsafe fn initWithCoder(
200            this: Allocated<Self>,
201            coder: &NSCoder,
202        ) -> Option<Retained<Self>>;
203    );
204}
205
206/// UICaptureTextFromCameraSupporting.
207#[cfg(feature = "UIMenuElement")]
208impl UIAction {
209    extern_methods!(
210        #[cfg(all(
211            feature = "UIResponder",
212            feature = "UITextInput",
213            feature = "UITextInputTraits"
214        ))]
215        /// Creates a new UIAction for the captureTextFromCamera: standard edit action.
216        ///
217        ///
218        /// Parameter `responder`: The UIKeyInput responder to send captureTextFromCamera: to.
219        ///
220        /// Parameter `identifier`: The action's identifier. Pass nil to use an auto-generated identifier.
221        ///
222        ///
223        /// Returns: A new UIAction.
224        #[unsafe(method(captureTextFromCameraActionForResponder:identifier:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn captureTextFromCameraActionForResponder_identifier(
227            responder: &UIResponder,
228            identifier: Option<&UIActionIdentifier>,
229        ) -> Retained<Self>;
230    );
231}