1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeymodifierflags?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIKeyModifierFlags(pub NSInteger);
bitflags::bitflags! {
impl UIKeyModifierFlags: NSInteger {
#[doc(alias = "UIKeyModifierAlphaShift")]
const AlphaShift = 1<<16;
#[doc(alias = "UIKeyModifierShift")]
const Shift = 1<<17;
#[doc(alias = "UIKeyModifierControl")]
const Control = 1<<18;
#[doc(alias = "UIKeyModifierAlternate")]
const Alternate = 1<<19;
#[doc(alias = "UIKeyModifierCommand")]
const Command = 1<<20;
#[doc(alias = "UIKeyModifierNumericPad")]
const NumericPad = 1<<21;
}
}
unsafe impl Encode for UIKeyModifierFlags {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIKeyModifierFlags {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// Represents an alternate action to take for a command.
///
/// Two alternates are equal iff their modifierFlags are equal.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicommandalternate?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UICommandAlternate;
);
extern_conformance!(
unsafe impl NSCoding for UICommandAlternate {}
);
extern_conformance!(
unsafe impl NSCopying for UICommandAlternate {}
);
unsafe impl CopyingHelper for UICommandAlternate {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for UICommandAlternate {}
);
extern_conformance!(
unsafe impl NSSecureCoding for UICommandAlternate {}
);
impl UICommandAlternate {
extern_methods!(
/// Short display title.
#[unsafe(method(title))]
#[unsafe(method_family = none)]
pub fn title(&self) -> Retained<NSString>;
/// Action to take on choosing this command alternate.
#[unsafe(method(action))]
#[unsafe(method_family = none)]
pub fn action(&self) -> Sel;
/// Bitmask of modifier flags to choose this command alternate.
#[unsafe(method(modifierFlags))]
#[unsafe(method_family = none)]
pub fn modifierFlags(&self) -> UIKeyModifierFlags;
/// Initialize an alternate action to take for a command.
///
///
/// Parameter `title`: Short display title. This should be localized.
///
/// Parameter `action`: Action to take on choosing this command alternate.
///
/// Parameter `modifierFlags`: Bitmask of modifier flags to choose this command alternate.
///
/// Returns: A new command alternate.
///
/// # Safety
///
/// `action` must be a valid selector.
#[unsafe(method(alternateWithTitle:action:modifierFlags:))]
#[unsafe(method_family = none)]
pub unsafe fn alternateWithTitle_action_modifierFlags(
title: &NSString,
action: Sel,
modifier_flags: UIKeyModifierFlags,
mtm: MainThreadMarker,
) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
);
}
extern_class!(
/// Represents an action to take.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicommand?language=objc)
#[unsafe(super(UIMenuElement, NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "UIMenuElement")]
pub struct UICommand;
);
#[cfg(feature = "UIMenuElement")]
extern_conformance!(
unsafe impl NSCoding for UICommand {}
);
#[cfg(feature = "UIMenuElement")]
extern_conformance!(
unsafe impl NSCopying for UICommand {}
);
#[cfg(feature = "UIMenuElement")]
unsafe impl CopyingHelper for UICommand {
type Result = Self;
}
#[cfg(feature = "UIMenuElement")]
extern_conformance!(
unsafe impl NSObjectProtocol for UICommand {}
);
#[cfg(feature = "UIMenuElement")]
extern_conformance!(
unsafe impl NSSecureCoding for UICommand {}
);
#[cfg(all(feature = "UIMenuElement", feature = "UIMenuLeaf"))]
extern_conformance!(
unsafe impl UIMenuLeaf for UICommand {}
);
#[cfg(feature = "UIMenuElement")]
impl UICommand {
extern_methods!(
/// Short display title.
#[unsafe(method(title))]
#[unsafe(method_family = none)]
pub fn title(&self) -> Retained<NSString>;
/// Setter for [`title`][Self::title].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setTitle:))]
#[unsafe(method_family = none)]
pub fn setTitle(&self, title: &NSString);
#[cfg(feature = "UIImage")]
/// Image that can appear next to this command
#[unsafe(method(image))]
#[unsafe(method_family = none)]
pub fn image(&self) -> Option<Retained<UIImage>>;
#[cfg(feature = "UIImage")]
/// Setter for [`image`][Self::image].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setImage:))]
#[unsafe(method_family = none)]
pub fn setImage(&self, image: Option<&UIImage>);
/// Elaborated title used in keyboard shortcut overlay.
#[unsafe(method(discoverabilityTitle))]
#[unsafe(method_family = none)]
pub fn discoverabilityTitle(&self) -> Option<Retained<NSString>>;
/// Setter for [`discoverabilityTitle`][Self::discoverabilityTitle].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setDiscoverabilityTitle:))]
#[unsafe(method_family = none)]
pub fn setDiscoverabilityTitle(&self, discoverability_title: Option<&NSString>);
/// Action to take on choosing this command.
#[unsafe(method(action))]
#[unsafe(method_family = none)]
pub unsafe fn action(&self) -> Sel;
/// Property list object to distinguish commands, if needed.
#[unsafe(method(propertyList))]
#[unsafe(method_family = none)]
pub fn propertyList(&self) -> Option<Retained<AnyObject>>;
/// Command attributes.
#[unsafe(method(attributes))]
#[unsafe(method_family = none)]
pub fn attributes(&self) -> UIMenuElementAttributes;
/// Setter for [`attributes`][Self::attributes].
#[unsafe(method(setAttributes:))]
#[unsafe(method_family = none)]
pub fn setAttributes(&self, attributes: UIMenuElementAttributes);
/// State that can appear next to the command.
#[unsafe(method(state))]
#[unsafe(method_family = none)]
pub fn state(&self) -> UIMenuElementState;
/// Setter for [`state`][Self::state].
#[unsafe(method(setState:))]
#[unsafe(method_family = none)]
pub fn setState(&self, state: UIMenuElementState);
/// Alternates that differ in modifier flags, if any.
#[unsafe(method(alternates))]
#[unsafe(method_family = none)]
pub fn alternates(&self) -> Retained<NSArray<UICommandAlternate>>;
#[cfg(feature = "UIImage")]
/// Initializes a keyless command.
///
///
/// Parameter `title`: Short display title. This should be localized.
///
/// Parameter `image`: Image that can appear next to this command, if needed.
///
/// Parameter `action`: Action to take on choosing this command.
///
/// Parameter `propertyList`: Property list object to distinguish commands, if needed.
///
/// Returns: A new keyless command.
///
/// # Safety
///
/// - `action` must be a valid selector.
/// - `property_list` should be of the correct type.
#[unsafe(method(commandWithTitle:image:action:propertyList:))]
#[unsafe(method_family = none)]
pub unsafe fn commandWithTitle_image_action_propertyList(
title: &NSString,
image: Option<&UIImage>,
action: Sel,
property_list: Option<&AnyObject>,
mtm: MainThreadMarker,
) -> Retained<Self>;
#[cfg(feature = "UIImage")]
/// Initializes a keyless command with alternates.
///
///
/// Parameter `title`: Short display title. This should be localized.
///
/// Parameter `image`: Image that can appear next to this command, if needed.
///
/// Parameter `action`: Action to take on choosing this command.
///
/// Parameter `propertyList`: Property list object to distinguish commands, if needed.
///
/// Parameter `alternates`: Alternates that differ in modifier flags.
///
/// Returns: A new keyless command with alternates.
///
/// # Safety
///
/// - `action` must be a valid selector.
/// - `property_list` should be of the correct type.
#[unsafe(method(commandWithTitle:image:action:propertyList:alternates:))]
#[unsafe(method_family = none)]
pub unsafe fn commandWithTitle_image_action_propertyList_alternates(
title: &NSString,
image: Option<&UIImage>,
action: Sel,
property_list: Option<&AnyObject>,
alternates: &NSArray<UICommandAlternate>,
mtm: MainThreadMarker,
) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
);
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicommandtagshare?language=objc)
pub static UICommandTagShare: &'static NSString;
}