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"))]
20unsafe impl NSCoding for UIKeyCommand {}
21
22#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
23unsafe impl NSCopying for UIKeyCommand {}
24
25#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
26unsafe impl CopyingHelper for UIKeyCommand {
27    type Result = Self;
28}
29
30#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
31unsafe impl NSObjectProtocol for UIKeyCommand {}
32
33#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
34unsafe impl NSSecureCoding for UIKeyCommand {}
35
36#[cfg(all(
37    feature = "UICommand",
38    feature = "UIMenuElement",
39    feature = "UIMenuLeaf"
40))]
41unsafe impl UIMenuLeaf for UIKeyCommand {}
42
43#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
44impl UIKeyCommand {
45    extern_methods!(
46        #[unsafe(method(init))]
47        #[unsafe(method_family = init)]
48        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
49
50        #[unsafe(method(initWithCoder:))]
51        #[unsafe(method_family = init)]
52        pub unsafe fn initWithCoder(
53            this: Allocated<Self>,
54            coder: &NSCoder,
55        ) -> Option<Retained<Self>>;
56
57        /// Short display title.
58        #[unsafe(method(title))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn title(&self) -> Retained<NSString>;
61
62        /// Setter for [`title`][Self::title].
63        #[unsafe(method(setTitle:))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn setTitle(&self, title: &NSString);
66
67        #[cfg(feature = "UIImage")]
68        /// Image that can appear next to this command.
69        #[unsafe(method(image))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
72
73        #[cfg(feature = "UIImage")]
74        /// Setter for [`image`][Self::image].
75        #[unsafe(method(setImage:))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn setImage(&self, image: Option<&UIImage>);
78
79        /// Elaborated title, if any.
80        #[unsafe(method(discoverabilityTitle))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn discoverabilityTitle(&self) -> Option<Retained<NSString>>;
83
84        /// Setter for [`discoverabilityTitle`][Self::discoverabilityTitle].
85        #[unsafe(method(setDiscoverabilityTitle:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn setDiscoverabilityTitle(&self, discoverability_title: Option<&NSString>);
88
89        /// Action to take on choosing this command.
90        #[unsafe(method(action))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn action(&self) -> Option<Sel>;
93
94        #[unsafe(method(input))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn input(&self) -> Option<Retained<NSString>>;
97
98        #[unsafe(method(modifierFlags))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn modifierFlags(&self) -> UIKeyModifierFlags;
101
102        /// Property list object to distinguish commands, if needed.
103        #[unsafe(method(propertyList))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn propertyList(&self) -> Option<Retained<AnyObject>>;
106
107        /// Command attributes.
108        #[unsafe(method(attributes))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn attributes(&self) -> UIMenuElementAttributes;
111
112        /// Setter for [`attributes`][Self::attributes].
113        #[unsafe(method(setAttributes:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setAttributes(&self, attributes: UIMenuElementAttributes);
116
117        /// State that can appear next to this command.
118        #[unsafe(method(state))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn state(&self) -> UIMenuElementState;
121
122        /// Setter for [`state`][Self::state].
123        #[unsafe(method(setState:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setState(&self, state: UIMenuElementState);
126
127        /// Alternates that differ in modifier flags, if any.
128        #[unsafe(method(alternates))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn alternates(&self) -> Retained<NSArray<UICommandAlternate>>;
131
132        /// Indicates whether the key command should execute if it conflicts with focus or text-editing system commands, defaults to
133        /// `NO`
134        #[unsafe(method(wantsPriorityOverSystemBehavior))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn wantsPriorityOverSystemBehavior(&self) -> bool;
137
138        /// Setter for [`wantsPriorityOverSystemBehavior`][Self::wantsPriorityOverSystemBehavior].
139        #[unsafe(method(setWantsPriorityOverSystemBehavior:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn setWantsPriorityOverSystemBehavior(
142            &self,
143            wants_priority_over_system_behavior: bool,
144        );
145
146        /// 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.
147        #[unsafe(method(allowsAutomaticLocalization))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn allowsAutomaticLocalization(&self) -> bool;
150
151        /// Setter for [`allowsAutomaticLocalization`][Self::allowsAutomaticLocalization].
152        #[unsafe(method(setAllowsAutomaticLocalization:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn setAllowsAutomaticLocalization(&self, allows_automatic_localization: bool);
155
156        /// Suppose the system detects a given key command with the following input string [ ] { } ( )
157        /// <
158        /// > ← → 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.
159        #[unsafe(method(allowsAutomaticMirroring))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn allowsAutomaticMirroring(&self) -> bool;
162
163        /// Setter for [`allowsAutomaticMirroring`][Self::allowsAutomaticMirroring].
164        #[unsafe(method(setAllowsAutomaticMirroring:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setAllowsAutomaticMirroring(&self, allows_automatic_mirroring: bool);
167
168        #[cfg(feature = "UIImage")]
169        /// Initializes a key command.
170        ///
171        ///
172        /// Parameter `title`: Short display title. This should be localized.
173        ///
174        /// Parameter `image`: Image that can appear next to this command, if needed.
175        ///
176        /// Parameter `action`: Action to take on choosing this command.
177        ///
178        /// Parameter `input`: Keys that must be pressed to choose this command.
179        ///
180        /// Parameter `modifierFlags`: Bit mask of key modifier flags to choose this command.
181        ///
182        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
183        ///
184        /// Returns: A new key command.
185        #[unsafe(method(commandWithTitle:image:action:input:modifierFlags:propertyList:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn commandWithTitle_image_action_input_modifierFlags_propertyList(
188            title: &NSString,
189            image: Option<&UIImage>,
190            action: Sel,
191            input: &NSString,
192            modifier_flags: UIKeyModifierFlags,
193            property_list: Option<&AnyObject>,
194            mtm: MainThreadMarker,
195        ) -> Retained<Self>;
196
197        #[cfg(feature = "UIImage")]
198        /// Initializes a key command with alternates.
199        ///
200        ///
201        /// Parameter `title`: Short display title. This should be localized.
202        ///
203        /// Parameter `image`: Image that can appear next to this command, if needed.
204        ///
205        /// Parameter `action`: Action to take on choosing this command.
206        ///
207        /// Parameter `input`: Keys that must be pressed to choose this command.
208        ///
209        /// Parameter `modifierFlags`: Bit mask of key modifier flags to choose this command.
210        ///
211        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
212        ///
213        /// Parameter `alternates`: Alternates that differ in modifier flags.
214        ///
215        /// Returns: A new key command.
216        #[unsafe(method(commandWithTitle:image:action:input:modifierFlags:propertyList:alternates:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn commandWithTitle_image_action_input_modifierFlags_propertyList_alternates(
219            title: &NSString,
220            image: Option<&UIImage>,
221            action: Sel,
222            input: &NSString,
223            modifier_flags: UIKeyModifierFlags,
224            property_list: Option<&AnyObject>,
225            alternates: &NSArray<UICommandAlternate>,
226            mtm: MainThreadMarker,
227        ) -> Retained<Self>;
228
229        #[unsafe(method(keyCommandWithInput:modifierFlags:action:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn keyCommandWithInput_modifierFlags_action(
232            input: &NSString,
233            modifier_flags: UIKeyModifierFlags,
234            action: Sel,
235            mtm: MainThreadMarker,
236        ) -> Retained<Self>;
237
238        #[deprecated]
239        #[unsafe(method(keyCommandWithInput:modifierFlags:action:discoverabilityTitle:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn keyCommandWithInput_modifierFlags_action_discoverabilityTitle(
242            input: &NSString,
243            modifier_flags: UIKeyModifierFlags,
244            action: Sel,
245            discoverability_title: &NSString,
246            mtm: MainThreadMarker,
247        ) -> Retained<Self>;
248
249        #[cfg(feature = "UIImage")]
250        #[unsafe(method(commandWithTitle:image:action:propertyList:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn commandWithTitle_image_action_propertyList(
253            title: &NSString,
254            image: Option<&UIImage>,
255            action: Sel,
256            property_list: Option<&AnyObject>,
257            mtm: MainThreadMarker,
258        ) -> Retained<Self>;
259
260        #[cfg(feature = "UIImage")]
261        #[unsafe(method(commandWithTitle:image:action:propertyList:alternates:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn commandWithTitle_image_action_propertyList_alternates(
264            title: &NSString,
265            image: Option<&UIImage>,
266            action: Sel,
267            property_list: Option<&AnyObject>,
268            alternates: &NSArray<UICommandAlternate>,
269            mtm: MainThreadMarker,
270        ) -> Retained<Self>;
271    );
272}
273
274/// Methods declared on superclass `UICommand`.
275#[cfg(all(feature = "UICommand", feature = "UIMenuElement"))]
276impl UIKeyCommand {
277    extern_methods!(
278        #[unsafe(method(new))]
279        #[unsafe(method_family = new)]
280        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
281    );
282}