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