objc2_app_kit/generated/
NSMenuItem.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 #[unsafe(super(NSObject))]
13 #[thread_kind = MainThreadOnly]
14 #[derive(Debug, PartialEq, Eq, Hash)]
15 pub struct NSMenuItem;
16);
17
18#[cfg(feature = "NSAccessibilityProtocols")]
19unsafe impl NSAccessibility for NSMenuItem {}
20
21#[cfg(feature = "NSAccessibilityProtocols")]
22unsafe impl NSAccessibilityElementProtocol for NSMenuItem {}
23
24unsafe impl NSCoding for NSMenuItem {}
25
26unsafe impl NSCopying for NSMenuItem {}
27
28unsafe impl CopyingHelper for NSMenuItem {
29 type Result = Self;
30}
31
32unsafe impl NSObjectProtocol for NSMenuItem {}
33
34#[cfg(feature = "NSUserInterfaceItemIdentification")]
35unsafe impl NSUserInterfaceItemIdentification for NSMenuItem {}
36
37#[cfg(feature = "NSUserInterfaceValidation")]
38unsafe impl NSValidatedUserInterfaceItem for NSMenuItem {}
39
40impl NSMenuItem {
41 extern_methods!(
42 #[unsafe(method(usesUserKeyEquivalents))]
43 #[unsafe(method_family = none)]
44 pub unsafe fn usesUserKeyEquivalents(mtm: MainThreadMarker) -> bool;
45
46 #[unsafe(method(setUsesUserKeyEquivalents:))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn setUsesUserKeyEquivalents(
50 uses_user_key_equivalents: bool,
51 mtm: MainThreadMarker,
52 );
53
54 #[unsafe(method(separatorItem))]
55 #[unsafe(method_family = none)]
56 pub fn separatorItem(mtm: MainThreadMarker) -> Retained<NSMenuItem>;
57
58 #[unsafe(method(sectionHeaderWithTitle:))]
62 #[unsafe(method_family = none)]
63 pub unsafe fn sectionHeaderWithTitle(
64 title: &NSString,
65 mtm: MainThreadMarker,
66 ) -> Retained<Self>;
67
68 #[unsafe(method(writingToolsItems))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn writingToolsItems(mtm: MainThreadMarker) -> Retained<NSArray<NSMenuItem>>;
73
74 #[unsafe(method(initWithTitle:action:keyEquivalent:))]
75 #[unsafe(method_family = init)]
76 pub unsafe fn initWithTitle_action_keyEquivalent(
77 this: Allocated<Self>,
78 string: &NSString,
79 selector: Option<Sel>,
80 char_code: &NSString,
81 ) -> Retained<Self>;
82
83 #[unsafe(method(initWithCoder:))]
84 #[unsafe(method_family = init)]
85 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
86
87 #[cfg(feature = "NSMenu")]
88 #[unsafe(method(menu))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn menu(&self) -> Option<Retained<NSMenu>>;
92
93 #[cfg(feature = "NSMenu")]
94 #[unsafe(method(setMenu:))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);
98
99 #[unsafe(method(hasSubmenu))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn hasSubmenu(&self) -> bool;
102
103 #[cfg(feature = "NSMenu")]
104 #[unsafe(method(submenu))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn submenu(&self) -> Option<Retained<NSMenu>>;
107
108 #[cfg(feature = "NSMenu")]
109 #[unsafe(method(setSubmenu:))]
111 #[unsafe(method_family = none)]
112 pub fn setSubmenu(&self, submenu: Option<&NSMenu>);
113
114 #[unsafe(method(parentItem))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn parentItem(&self) -> Option<Retained<NSMenuItem>>;
118
119 #[unsafe(method(title))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn title(&self) -> Retained<NSString>;
122
123 #[unsafe(method(setTitle:))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn setTitle(&self, title: &NSString);
127
128 #[unsafe(method(attributedTitle))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn attributedTitle(&self) -> Option<Retained<NSAttributedString>>;
131
132 #[unsafe(method(setAttributedTitle:))]
134 #[unsafe(method_family = none)]
135 pub unsafe fn setAttributedTitle(&self, attributed_title: Option<&NSAttributedString>);
136
137 #[unsafe(method(subtitle))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;
145
146 #[unsafe(method(setSubtitle:))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn setSubtitle(&self, subtitle: Option<&NSString>);
150
151 #[unsafe(method(isSeparatorItem))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn isSeparatorItem(&self) -> bool;
154
155 #[unsafe(method(isSectionHeader))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn isSectionHeader(&self) -> bool;
160
161 #[unsafe(method(keyEquivalent))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn keyEquivalent(&self) -> Retained<NSString>;
164
165 #[unsafe(method(setKeyEquivalent:))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn setKeyEquivalent(&self, key_equivalent: &NSString);
169
170 #[cfg(feature = "NSEvent")]
171 #[unsafe(method(keyEquivalentModifierMask))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn keyEquivalentModifierMask(&self) -> NSEventModifierFlags;
174
175 #[cfg(feature = "NSEvent")]
176 #[unsafe(method(setKeyEquivalentModifierMask:))]
178 #[unsafe(method_family = none)]
179 pub fn setKeyEquivalentModifierMask(
180 &self,
181 key_equivalent_modifier_mask: NSEventModifierFlags,
182 );
183
184 #[unsafe(method(userKeyEquivalent))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn userKeyEquivalent(&self) -> Retained<NSString>;
187
188 #[unsafe(method(allowsKeyEquivalentWhenHidden))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn allowsKeyEquivalentWhenHidden(&self) -> bool;
191
192 #[unsafe(method(setAllowsKeyEquivalentWhenHidden:))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn setAllowsKeyEquivalentWhenHidden(
196 &self,
197 allows_key_equivalent_when_hidden: bool,
198 );
199
200 #[unsafe(method(allowsAutomaticKeyEquivalentLocalization))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn allowsAutomaticKeyEquivalentLocalization(&self) -> bool;
203
204 #[unsafe(method(setAllowsAutomaticKeyEquivalentLocalization:))]
206 #[unsafe(method_family = none)]
207 pub unsafe fn setAllowsAutomaticKeyEquivalentLocalization(
208 &self,
209 allows_automatic_key_equivalent_localization: bool,
210 );
211
212 #[unsafe(method(allowsAutomaticKeyEquivalentMirroring))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn allowsAutomaticKeyEquivalentMirroring(&self) -> bool;
215
216 #[unsafe(method(setAllowsAutomaticKeyEquivalentMirroring:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn setAllowsAutomaticKeyEquivalentMirroring(
220 &self,
221 allows_automatic_key_equivalent_mirroring: bool,
222 );
223
224 #[cfg(feature = "NSImage")]
225 #[unsafe(method(image))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
228
229 #[cfg(feature = "NSImage")]
230 #[unsafe(method(setImage:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn setImage(&self, image: Option<&NSImage>);
234
235 #[cfg(feature = "NSCell")]
236 #[unsafe(method(state))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn state(&self) -> NSControlStateValue;
239
240 #[cfg(feature = "NSCell")]
241 #[unsafe(method(setState:))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn setState(&self, state: NSControlStateValue);
245
246 #[cfg(feature = "NSImage")]
247 #[unsafe(method(onStateImage))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn onStateImage(&self) -> Option<Retained<NSImage>>;
250
251 #[cfg(feature = "NSImage")]
252 #[unsafe(method(setOnStateImage:))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn setOnStateImage(&self, on_state_image: Option<&NSImage>);
256
257 #[cfg(feature = "NSImage")]
258 #[unsafe(method(offStateImage))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn offStateImage(&self) -> Option<Retained<NSImage>>;
261
262 #[cfg(feature = "NSImage")]
263 #[unsafe(method(setOffStateImage:))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn setOffStateImage(&self, off_state_image: Option<&NSImage>);
267
268 #[cfg(feature = "NSImage")]
269 #[unsafe(method(mixedStateImage))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn mixedStateImage(&self) -> Option<Retained<NSImage>>;
272
273 #[cfg(feature = "NSImage")]
274 #[unsafe(method(setMixedStateImage:))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn setMixedStateImage(&self, mixed_state_image: Option<&NSImage>);
278
279 #[unsafe(method(isEnabled))]
280 #[unsafe(method_family = none)]
281 pub unsafe fn isEnabled(&self) -> bool;
282
283 #[unsafe(method(setEnabled:))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn setEnabled(&self, enabled: bool);
287
288 #[unsafe(method(isAlternate))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn isAlternate(&self) -> bool;
291
292 #[unsafe(method(setAlternate:))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn setAlternate(&self, alternate: bool);
296
297 #[unsafe(method(indentationLevel))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn indentationLevel(&self) -> NSInteger;
300
301 #[unsafe(method(setIndentationLevel:))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn setIndentationLevel(&self, indentation_level: NSInteger);
305
306 #[unsafe(method(target))]
307 #[unsafe(method_family = none)]
308 pub unsafe fn target(&self) -> Option<Retained<AnyObject>>;
309
310 #[unsafe(method(setTarget:))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
315
316 #[unsafe(method(action))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn action(&self) -> Option<Sel>;
319
320 #[unsafe(method(setAction:))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn setAction(&self, action: Option<Sel>);
324
325 #[unsafe(method(tag))]
326 #[unsafe(method_family = none)]
327 pub unsafe fn tag(&self) -> NSInteger;
328
329 #[unsafe(method(setTag:))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn setTag(&self, tag: NSInteger);
333
334 #[unsafe(method(representedObject))]
335 #[unsafe(method_family = none)]
336 pub unsafe fn representedObject(&self) -> Option<Retained<AnyObject>>;
337
338 #[unsafe(method(setRepresentedObject:))]
340 #[unsafe(method_family = none)]
341 pub unsafe fn setRepresentedObject(&self, represented_object: Option<&AnyObject>);
342
343 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
344 #[unsafe(method(view))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn view(&self) -> Option<Retained<NSView>>;
347
348 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
349 #[unsafe(method(setView:))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn setView(&self, view: Option<&NSView>);
353
354 #[unsafe(method(isHighlighted))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn isHighlighted(&self) -> bool;
357
358 #[unsafe(method(isHidden))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn isHidden(&self) -> bool;
361
362 #[unsafe(method(setHidden:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn setHidden(&self, hidden: bool);
366
367 #[unsafe(method(isHiddenOrHasHiddenAncestor))]
368 #[unsafe(method_family = none)]
369 pub unsafe fn isHiddenOrHasHiddenAncestor(&self) -> bool;
370
371 #[unsafe(method(toolTip))]
372 #[unsafe(method_family = none)]
373 pub unsafe fn toolTip(&self) -> Option<Retained<NSString>>;
374
375 #[unsafe(method(setToolTip:))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>);
379
380 #[cfg(feature = "NSMenuItemBadge")]
381 #[unsafe(method(badge))]
388 #[unsafe(method_family = none)]
389 pub unsafe fn badge(&self) -> Option<Retained<NSMenuItemBadge>>;
390
391 #[cfg(feature = "NSMenuItemBadge")]
392 #[unsafe(method(setBadge:))]
394 #[unsafe(method_family = none)]
395 pub unsafe fn setBadge(&self, badge: Option<&NSMenuItemBadge>);
396 );
397}
398
399impl NSMenuItem {
401 extern_methods!(
402 #[unsafe(method(init))]
403 #[unsafe(method_family = init)]
404 pub fn init(this: Allocated<Self>) -> Retained<Self>;
405
406 #[unsafe(method(new))]
407 #[unsafe(method_family = new)]
408 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
409 );
410}
411
412#[cfg(all(feature = "NSResponder", feature = "NSView"))]
414impl NSView {
415 extern_methods!(
416 #[unsafe(method(enclosingMenuItem))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn enclosingMenuItem(&self) -> Option<Retained<NSMenuItem>>;
419 );
420}
421
422extern "C" {
423 #[cfg(feature = "NSUserInterfaceItemIdentification")]
425 pub static NSMenuItemImportFromDeviceIdentifier: &'static NSUserInterfaceItemIdentifier;
426}
427
428impl NSMenuItem {
430 extern_methods!(
431 #[deprecated]
432 #[unsafe(method(setMnemonicLocation:))]
433 #[unsafe(method_family = none)]
434 pub unsafe fn setMnemonicLocation(&self, location: NSUInteger);
435
436 #[deprecated]
437 #[unsafe(method(mnemonicLocation))]
438 #[unsafe(method_family = none)]
439 pub unsafe fn mnemonicLocation(&self) -> NSUInteger;
440
441 #[deprecated]
442 #[unsafe(method(mnemonic))]
443 #[unsafe(method_family = none)]
444 pub unsafe fn mnemonic(&self) -> Option<Retained<NSString>>;
445
446 #[deprecated]
447 #[unsafe(method(setTitleWithMnemonic:))]
448 #[unsafe(method_family = none)]
449 pub unsafe fn setTitleWithMnemonic(&self, string_with_ampersand: &NSString);
450 );
451}