objc2_ui_kit/generated/
UIKeyCommand.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
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeycommand?language=objc)
12    #[unsafe(super(UICommand, UIMenuElement, NSObject))]
13    #[thread_kind = MainThreadOnly]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    #[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
16    pub struct UIKeyCommand;
17);
18
19#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
20extern_conformance!(
21    unsafe impl NSCoding for UIKeyCommand {}
22);
23
24#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
25extern_conformance!(
26    unsafe impl NSCopying for UIKeyCommand {}
27);
28
29#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
30unsafe impl CopyingHelper for UIKeyCommand {
31    type Result = Self;
32}
33
34#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
35extern_conformance!(
36    unsafe impl NSObjectProtocol for UIKeyCommand {}
37);
38
39#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
40extern_conformance!(
41    unsafe impl NSSecureCoding for UIKeyCommand {}
42);
43
44#[cfg(all(
45    feature = "UICommand",
46    feature = "UIMenuElement",
47    feature = "UIMenuLeaf"
48))]
49extern_conformance!(
50    unsafe impl UIMenuLeaf for UIKeyCommand {}
51);
52
53#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
54impl UIKeyCommand {
55    extern_methods!(
56        #[unsafe(method(init))]
57        #[unsafe(method_family = init)]
58        pub fn init(this: Allocated<Self>) -> Retained<Self>;
59
60        /// # Safety
61        ///
62        /// `coder` possibly has further requirements.
63        #[unsafe(method(initWithCoder:))]
64        #[unsafe(method_family = init)]
65        pub unsafe fn initWithCoder(
66            this: Allocated<Self>,
67            coder: &NSCoder,
68        ) -> Option<Retained<Self>>;
69
70        /// Short display title.
71        #[unsafe(method(title))]
72        #[unsafe(method_family = none)]
73        pub fn title(&self) -> Retained<NSString>;
74
75        /// Setter for [`title`][Self::title].
76        ///
77        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
78        #[unsafe(method(setTitle:))]
79        #[unsafe(method_family = none)]
80        pub fn setTitle(&self, title: &NSString);
81
82        #[cfg(feature = "UIImage")]
83        /// Image that can appear next to this command.
84        #[unsafe(method(image))]
85        #[unsafe(method_family = none)]
86        pub fn image(&self) -> Option<Retained<UIImage>>;
87
88        #[cfg(feature = "UIImage")]
89        /// Setter for [`image`][Self::image].
90        ///
91        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
92        #[unsafe(method(setImage:))]
93        #[unsafe(method_family = none)]
94        pub fn setImage(&self, image: Option<&UIImage>);
95
96        /// Elaborated title, if any.
97        #[unsafe(method(discoverabilityTitle))]
98        #[unsafe(method_family = none)]
99        pub fn discoverabilityTitle(&self) -> Option<Retained<NSString>>;
100
101        /// Setter for [`discoverabilityTitle`][Self::discoverabilityTitle].
102        ///
103        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
104        #[unsafe(method(setDiscoverabilityTitle:))]
105        #[unsafe(method_family = none)]
106        pub fn setDiscoverabilityTitle(&self, discoverability_title: Option<&NSString>);
107
108        /// Action to take on choosing this command.
109        #[unsafe(method(action))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn action(&self) -> Option<Sel>;
112
113        #[unsafe(method(input))]
114        #[unsafe(method_family = none)]
115        pub fn input(&self) -> Option<Retained<NSString>>;
116
117        #[unsafe(method(modifierFlags))]
118        #[unsafe(method_family = none)]
119        pub fn modifierFlags(&self) -> UIKeyModifierFlags;
120
121        /// Property list object to distinguish commands, if needed.
122        #[unsafe(method(propertyList))]
123        #[unsafe(method_family = none)]
124        pub fn propertyList(&self) -> Option<Retained<AnyObject>>;
125
126        /// Command attributes.
127        #[unsafe(method(attributes))]
128        #[unsafe(method_family = none)]
129        pub fn attributes(&self) -> UIMenuElementAttributes;
130
131        /// Setter for [`attributes`][Self::attributes].
132        #[unsafe(method(setAttributes:))]
133        #[unsafe(method_family = none)]
134        pub fn setAttributes(&self, attributes: UIMenuElementAttributes);
135
136        /// State that can appear next to this command.
137        #[unsafe(method(state))]
138        #[unsafe(method_family = none)]
139        pub fn state(&self) -> UIMenuElementState;
140
141        /// Setter for [`state`][Self::state].
142        #[unsafe(method(setState:))]
143        #[unsafe(method_family = none)]
144        pub fn setState(&self, state: UIMenuElementState);
145
146        /// Alternates that differ in modifier flags, if any.
147        #[unsafe(method(alternates))]
148        #[unsafe(method_family = none)]
149        pub fn alternates(&self) -> Retained<NSArray<UICommandAlternate>>;
150
151        /// Indicates whether the key command should execute if it conflicts with focus or text-editing system commands, defaults to
152        /// `NO`
153        #[unsafe(method(wantsPriorityOverSystemBehavior))]
154        #[unsafe(method_family = none)]
155        pub fn wantsPriorityOverSystemBehavior(&self) -> bool;
156
157        /// Setter for [`wantsPriorityOverSystemBehavior`][Self::wantsPriorityOverSystemBehavior].
158        #[unsafe(method(setWantsPriorityOverSystemBehavior:))]
159        #[unsafe(method_family = none)]
160        pub fn setWantsPriorityOverSystemBehavior(&self, wants_priority_over_system_behavior: bool);
161
162        /// Suppose the system detects a given key command that is not reachable in the current keyboard layout; it will localize the key command to something reachable. By setting this property to NO, you will opt-out this menu item from the system-provided localization. YES by default for apps linked against 15.0 and later SDK.
163        #[unsafe(method(allowsAutomaticLocalization))]
164        #[unsafe(method_family = none)]
165        pub fn allowsAutomaticLocalization(&self) -> bool;
166
167        /// Setter for [`allowsAutomaticLocalization`][Self::allowsAutomaticLocalization].
168        #[unsafe(method(setAllowsAutomaticLocalization:))]
169        #[unsafe(method_family = none)]
170        pub fn setAllowsAutomaticLocalization(&self, allows_automatic_localization: bool);
171
172        /// Suppose the system detects a given key command with the following input string [ ] { } ( )
173        /// <
174        /// > ← → in a right-to-left user interface environment (UIUserInterfaceLayoutDirectionRightToLeft); in that case, the system will automatically mirror the key command. For example, a pair of key commands with input { and } will be localized to } and { in a right-to-left user interface. By setting this property to NO, you will opt-out this key command of automatically mirroring in RTL. It would be best only to do this if your action will result in some sort of directional change in the UI, e.g. a segmented control for text alignment or a D-pad in a game. YES by default for apps linked against 15.0 and later SDK.
175        #[unsafe(method(allowsAutomaticMirroring))]
176        #[unsafe(method_family = none)]
177        pub fn allowsAutomaticMirroring(&self) -> bool;
178
179        /// Setter for [`allowsAutomaticMirroring`][Self::allowsAutomaticMirroring].
180        #[unsafe(method(setAllowsAutomaticMirroring:))]
181        #[unsafe(method_family = none)]
182        pub fn setAllowsAutomaticMirroring(&self, allows_automatic_mirroring: bool);
183
184        #[cfg(feature = "UIImage")]
185        /// Initializes a key command.
186        ///
187        ///
188        /// Parameter `title`: Short display title. This should be localized.
189        ///
190        /// Parameter `image`: Image that can appear next to this command, if needed.
191        ///
192        /// Parameter `action`: Action to take on choosing this command.
193        ///
194        /// Parameter `input`: Keys that must be pressed to choose this command.
195        ///
196        /// Parameter `modifierFlags`: Bit mask of key modifier flags to choose this command.
197        ///
198        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
199        ///
200        /// Returns: A new key command.
201        ///
202        /// # Safety
203        ///
204        /// - `action` must be a valid selector.
205        /// - `property_list` should be of the correct type.
206        #[unsafe(method(commandWithTitle:image:action:input:modifierFlags:propertyList:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn commandWithTitle_image_action_input_modifierFlags_propertyList(
209            title: &NSString,
210            image: Option<&UIImage>,
211            action: Sel,
212            input: &NSString,
213            modifier_flags: UIKeyModifierFlags,
214            property_list: Option<&AnyObject>,
215            mtm: MainThreadMarker,
216        ) -> Retained<Self>;
217
218        #[cfg(feature = "UIImage")]
219        /// Initializes a key command with alternates.
220        ///
221        ///
222        /// Parameter `title`: Short display title. This should be localized.
223        ///
224        /// Parameter `image`: Image that can appear next to this command, if needed.
225        ///
226        /// Parameter `action`: Action to take on choosing this command.
227        ///
228        /// Parameter `input`: Keys that must be pressed to choose this command.
229        ///
230        /// Parameter `modifierFlags`: Bit mask of key modifier flags to choose this command.
231        ///
232        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
233        ///
234        /// Parameter `alternates`: Alternates that differ in modifier flags.
235        ///
236        /// Returns: A new key command.
237        ///
238        /// # Safety
239        ///
240        /// - `action` must be a valid selector.
241        /// - `property_list` should be of the correct type.
242        #[unsafe(method(commandWithTitle:image:action:input:modifierFlags:propertyList:alternates:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn commandWithTitle_image_action_input_modifierFlags_propertyList_alternates(
245            title: &NSString,
246            image: Option<&UIImage>,
247            action: Sel,
248            input: &NSString,
249            modifier_flags: UIKeyModifierFlags,
250            property_list: Option<&AnyObject>,
251            alternates: &NSArray<UICommandAlternate>,
252            mtm: MainThreadMarker,
253        ) -> Retained<Self>;
254
255        /// # Safety
256        ///
257        /// `action` must be a valid selector.
258        #[unsafe(method(keyCommandWithInput:modifierFlags:action:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn keyCommandWithInput_modifierFlags_action(
261            input: &NSString,
262            modifier_flags: UIKeyModifierFlags,
263            action: Sel,
264            mtm: MainThreadMarker,
265        ) -> Retained<Self>;
266
267        /// # Safety
268        ///
269        /// `action` must be a valid selector.
270        #[deprecated]
271        #[unsafe(method(keyCommandWithInput:modifierFlags:action:discoverabilityTitle:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn keyCommandWithInput_modifierFlags_action_discoverabilityTitle(
274            input: &NSString,
275            modifier_flags: UIKeyModifierFlags,
276            action: Sel,
277            discoverability_title: &NSString,
278            mtm: MainThreadMarker,
279        ) -> Retained<Self>;
280
281        #[cfg(feature = "UIImage")]
282        /// # Safety
283        ///
284        /// - `action` must be a valid selector.
285        /// - `property_list` should be of the correct type.
286        #[unsafe(method(commandWithTitle:image:action:propertyList:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn commandWithTitle_image_action_propertyList(
289            title: &NSString,
290            image: Option<&UIImage>,
291            action: Sel,
292            property_list: Option<&AnyObject>,
293            mtm: MainThreadMarker,
294        ) -> Retained<Self>;
295
296        #[cfg(feature = "UIImage")]
297        /// # Safety
298        ///
299        /// - `action` must be a valid selector.
300        /// - `property_list` should be of the correct type.
301        #[unsafe(method(commandWithTitle:image:action:propertyList:alternates:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn commandWithTitle_image_action_propertyList_alternates(
304            title: &NSString,
305            image: Option<&UIImage>,
306            action: Sel,
307            property_list: Option<&AnyObject>,
308            alternates: &NSArray<UICommandAlternate>,
309            mtm: MainThreadMarker,
310        ) -> Retained<Self>;
311    );
312}
313
314/// Methods declared on superclass `UICommand`.
315#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
316impl UIKeyCommand {
317    extern_methods!(
318        #[unsafe(method(new))]
319        #[unsafe(method_family = new)]
320        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
321    );
322}