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