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")]
19extern_conformance!(
20 unsafe impl NSAccessibility for NSMenuItem {}
21);
22
23#[cfg(feature = "NSAccessibilityProtocols")]
24extern_conformance!(
25 unsafe impl NSAccessibilityElementProtocol for NSMenuItem {}
26);
27
28extern_conformance!(
29 unsafe impl NSCoding for NSMenuItem {}
30);
31
32extern_conformance!(
33 unsafe impl NSCopying for NSMenuItem {}
34);
35
36unsafe impl CopyingHelper for NSMenuItem {
37 type Result = Self;
38}
39
40extern_conformance!(
41 unsafe impl NSObjectProtocol for NSMenuItem {}
42);
43
44#[cfg(feature = "NSUserInterfaceItemIdentification")]
45extern_conformance!(
46 unsafe impl NSUserInterfaceItemIdentification for NSMenuItem {}
47);
48
49#[cfg(feature = "NSUserInterfaceValidation")]
50extern_conformance!(
51 unsafe impl NSValidatedUserInterfaceItem for NSMenuItem {}
52);
53
54impl NSMenuItem {
55 extern_methods!(
56 #[unsafe(method(usesUserKeyEquivalents))]
57 #[unsafe(method_family = none)]
58 pub fn usesUserKeyEquivalents(mtm: MainThreadMarker) -> bool;
59
60 #[unsafe(method(setUsesUserKeyEquivalents:))]
62 #[unsafe(method_family = none)]
63 pub fn setUsesUserKeyEquivalents(uses_user_key_equivalents: bool, mtm: MainThreadMarker);
64
65 #[unsafe(method(separatorItem))]
66 #[unsafe(method_family = none)]
67 pub fn separatorItem(mtm: MainThreadMarker) -> Retained<NSMenuItem>;
68
69 #[unsafe(method(sectionHeaderWithTitle:))]
73 #[unsafe(method_family = none)]
74 pub fn sectionHeaderWithTitle(title: &NSString, mtm: MainThreadMarker) -> Retained<Self>;
75
76 #[unsafe(method(writingToolsItems))]
79 #[unsafe(method_family = none)]
80 pub fn writingToolsItems(mtm: MainThreadMarker) -> Retained<NSArray<NSMenuItem>>;
81
82 #[unsafe(method(initWithTitle:action:keyEquivalent:))]
86 #[unsafe(method_family = init)]
87 pub unsafe fn initWithTitle_action_keyEquivalent(
88 this: Allocated<Self>,
89 string: &NSString,
90 selector: Option<Sel>,
91 char_code: &NSString,
92 ) -> Retained<Self>;
93
94 #[unsafe(method(initWithCoder:))]
98 #[unsafe(method_family = init)]
99 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
100
101 #[cfg(feature = "NSMenu")]
102 #[unsafe(method(menu))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn menu(&self) -> Option<Retained<NSMenu>>;
110
111 #[cfg(feature = "NSMenu")]
112 #[unsafe(method(setMenu:))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);
120
121 #[unsafe(method(hasSubmenu))]
122 #[unsafe(method_family = none)]
123 pub fn hasSubmenu(&self) -> bool;
124
125 #[cfg(feature = "NSMenu")]
126 #[unsafe(method(submenu))]
127 #[unsafe(method_family = none)]
128 pub fn submenu(&self) -> Option<Retained<NSMenu>>;
129
130 #[cfg(feature = "NSMenu")]
131 #[unsafe(method(setSubmenu:))]
133 #[unsafe(method_family = none)]
134 pub fn setSubmenu(&self, submenu: Option<&NSMenu>);
135
136 #[unsafe(method(parentItem))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn parentItem(&self) -> Option<Retained<NSMenuItem>>;
144
145 #[unsafe(method(title))]
146 #[unsafe(method_family = none)]
147 pub fn title(&self) -> Retained<NSString>;
148
149 #[unsafe(method(setTitle:))]
153 #[unsafe(method_family = none)]
154 pub fn setTitle(&self, title: &NSString);
155
156 #[unsafe(method(attributedTitle))]
157 #[unsafe(method_family = none)]
158 pub fn attributedTitle(&self) -> Option<Retained<NSAttributedString>>;
159
160 #[unsafe(method(setAttributedTitle:))]
164 #[unsafe(method_family = none)]
165 pub fn setAttributedTitle(&self, attributed_title: Option<&NSAttributedString>);
166
167 #[unsafe(method(subtitle))]
173 #[unsafe(method_family = none)]
174 pub fn subtitle(&self) -> Option<Retained<NSString>>;
175
176 #[unsafe(method(setSubtitle:))]
180 #[unsafe(method_family = none)]
181 pub fn setSubtitle(&self, subtitle: Option<&NSString>);
182
183 #[unsafe(method(isSeparatorItem))]
184 #[unsafe(method_family = none)]
185 pub fn isSeparatorItem(&self) -> bool;
186
187 #[unsafe(method(isSectionHeader))]
190 #[unsafe(method_family = none)]
191 pub fn isSectionHeader(&self) -> bool;
192
193 #[unsafe(method(keyEquivalent))]
194 #[unsafe(method_family = none)]
195 pub fn keyEquivalent(&self) -> Retained<NSString>;
196
197 #[unsafe(method(setKeyEquivalent:))]
201 #[unsafe(method_family = none)]
202 pub fn setKeyEquivalent(&self, key_equivalent: &NSString);
203
204 #[cfg(feature = "NSEvent")]
205 #[unsafe(method(keyEquivalentModifierMask))]
206 #[unsafe(method_family = none)]
207 pub fn keyEquivalentModifierMask(&self) -> NSEventModifierFlags;
208
209 #[cfg(feature = "NSEvent")]
210 #[unsafe(method(setKeyEquivalentModifierMask:))]
212 #[unsafe(method_family = none)]
213 pub fn setKeyEquivalentModifierMask(
214 &self,
215 key_equivalent_modifier_mask: NSEventModifierFlags,
216 );
217
218 #[unsafe(method(userKeyEquivalent))]
219 #[unsafe(method_family = none)]
220 pub fn userKeyEquivalent(&self) -> Retained<NSString>;
221
222 #[unsafe(method(allowsKeyEquivalentWhenHidden))]
223 #[unsafe(method_family = none)]
224 pub fn allowsKeyEquivalentWhenHidden(&self) -> bool;
225
226 #[unsafe(method(setAllowsKeyEquivalentWhenHidden:))]
228 #[unsafe(method_family = none)]
229 pub fn setAllowsKeyEquivalentWhenHidden(&self, allows_key_equivalent_when_hidden: bool);
230
231 #[unsafe(method(allowsAutomaticKeyEquivalentLocalization))]
232 #[unsafe(method_family = none)]
233 pub fn allowsAutomaticKeyEquivalentLocalization(&self) -> bool;
234
235 #[unsafe(method(setAllowsAutomaticKeyEquivalentLocalization:))]
237 #[unsafe(method_family = none)]
238 pub fn setAllowsAutomaticKeyEquivalentLocalization(
239 &self,
240 allows_automatic_key_equivalent_localization: bool,
241 );
242
243 #[unsafe(method(allowsAutomaticKeyEquivalentMirroring))]
244 #[unsafe(method_family = none)]
245 pub fn allowsAutomaticKeyEquivalentMirroring(&self) -> bool;
246
247 #[unsafe(method(setAllowsAutomaticKeyEquivalentMirroring:))]
249 #[unsafe(method_family = none)]
250 pub fn setAllowsAutomaticKeyEquivalentMirroring(
251 &self,
252 allows_automatic_key_equivalent_mirroring: bool,
253 );
254
255 #[cfg(feature = "NSImage")]
256 #[unsafe(method(image))]
257 #[unsafe(method_family = none)]
258 pub fn image(&self) -> Option<Retained<NSImage>>;
259
260 #[cfg(feature = "NSImage")]
261 #[unsafe(method(setImage:))]
263 #[unsafe(method_family = none)]
264 pub fn setImage(&self, image: Option<&NSImage>);
265
266 #[cfg(feature = "NSCell")]
267 #[unsafe(method(state))]
268 #[unsafe(method_family = none)]
269 pub fn state(&self) -> NSControlStateValue;
270
271 #[cfg(feature = "NSCell")]
272 #[unsafe(method(setState:))]
274 #[unsafe(method_family = none)]
275 pub fn setState(&self, state: NSControlStateValue);
276
277 #[cfg(feature = "NSImage")]
278 #[unsafe(method(onStateImage))]
279 #[unsafe(method_family = none)]
280 pub fn onStateImage(&self) -> Option<Retained<NSImage>>;
281
282 #[cfg(feature = "NSImage")]
283 #[unsafe(method(setOnStateImage:))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn setOnStateImage(&self, on_state_image: Option<&NSImage>);
291
292 #[cfg(feature = "NSImage")]
293 #[unsafe(method(offStateImage))]
294 #[unsafe(method_family = none)]
295 pub fn offStateImage(&self) -> Option<Retained<NSImage>>;
296
297 #[cfg(feature = "NSImage")]
298 #[unsafe(method(setOffStateImage:))]
300 #[unsafe(method_family = none)]
301 pub fn setOffStateImage(&self, off_state_image: Option<&NSImage>);
302
303 #[cfg(feature = "NSImage")]
304 #[unsafe(method(mixedStateImage))]
305 #[unsafe(method_family = none)]
306 pub fn mixedStateImage(&self) -> Option<Retained<NSImage>>;
307
308 #[cfg(feature = "NSImage")]
309 #[unsafe(method(setMixedStateImage:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn setMixedStateImage(&self, mixed_state_image: Option<&NSImage>);
317
318 #[unsafe(method(isEnabled))]
319 #[unsafe(method_family = none)]
320 pub fn isEnabled(&self) -> bool;
321
322 #[unsafe(method(setEnabled:))]
324 #[unsafe(method_family = none)]
325 pub fn setEnabled(&self, enabled: bool);
326
327 #[unsafe(method(isAlternate))]
328 #[unsafe(method_family = none)]
329 pub fn isAlternate(&self) -> bool;
330
331 #[unsafe(method(setAlternate:))]
333 #[unsafe(method_family = none)]
334 pub fn setAlternate(&self, alternate: bool);
335
336 #[unsafe(method(indentationLevel))]
337 #[unsafe(method_family = none)]
338 pub fn indentationLevel(&self) -> NSInteger;
339
340 #[unsafe(method(setIndentationLevel:))]
342 #[unsafe(method_family = none)]
343 pub fn setIndentationLevel(&self, indentation_level: NSInteger);
344
345 #[unsafe(method(target))]
346 #[unsafe(method_family = none)]
347 pub fn target(&self) -> Option<Retained<AnyObject>>;
348
349 #[unsafe(method(setTarget:))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
359
360 #[unsafe(method(action))]
361 #[unsafe(method_family = none)]
362 pub fn action(&self) -> Option<Sel>;
363
364 #[unsafe(method(setAction:))]
370 #[unsafe(method_family = none)]
371 pub unsafe fn setAction(&self, action: Option<Sel>);
372
373 #[unsafe(method(tag))]
374 #[unsafe(method_family = none)]
375 pub fn tag(&self) -> NSInteger;
376
377 #[unsafe(method(setTag:))]
379 #[unsafe(method_family = none)]
380 pub fn setTag(&self, tag: NSInteger);
381
382 #[unsafe(method(representedObject))]
383 #[unsafe(method_family = none)]
384 pub fn representedObject(&self) -> Option<Retained<AnyObject>>;
385
386 #[unsafe(method(setRepresentedObject:))]
392 #[unsafe(method_family = none)]
393 pub unsafe fn setRepresentedObject(&self, represented_object: Option<&AnyObject>);
394
395 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
396 #[unsafe(method(view))]
397 #[unsafe(method_family = none)]
398 pub fn view(&self) -> Option<Retained<NSView>>;
399
400 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
401 #[unsafe(method(setView:))]
403 #[unsafe(method_family = none)]
404 pub fn setView(&self, view: Option<&NSView>);
405
406 #[unsafe(method(isHighlighted))]
407 #[unsafe(method_family = none)]
408 pub fn isHighlighted(&self) -> bool;
409
410 #[unsafe(method(isHidden))]
411 #[unsafe(method_family = none)]
412 pub fn isHidden(&self) -> bool;
413
414 #[unsafe(method(setHidden:))]
416 #[unsafe(method_family = none)]
417 pub fn setHidden(&self, hidden: bool);
418
419 #[unsafe(method(isHiddenOrHasHiddenAncestor))]
420 #[unsafe(method_family = none)]
421 pub fn isHiddenOrHasHiddenAncestor(&self) -> bool;
422
423 #[unsafe(method(toolTip))]
424 #[unsafe(method_family = none)]
425 pub fn toolTip(&self) -> Option<Retained<NSString>>;
426
427 #[unsafe(method(setToolTip:))]
431 #[unsafe(method_family = none)]
432 pub fn setToolTip(&self, tool_tip: Option<&NSString>);
433
434 #[cfg(feature = "NSMenuItemBadge")]
435 #[unsafe(method(badge))]
442 #[unsafe(method_family = none)]
443 pub fn badge(&self) -> Option<Retained<NSMenuItemBadge>>;
444
445 #[cfg(feature = "NSMenuItemBadge")]
446 #[unsafe(method(setBadge:))]
450 #[unsafe(method_family = none)]
451 pub fn setBadge(&self, badge: Option<&NSMenuItemBadge>);
452 );
453}
454
455impl NSMenuItem {
457 extern_methods!(
458 #[unsafe(method(init))]
459 #[unsafe(method_family = init)]
460 pub fn init(this: Allocated<Self>) -> Retained<Self>;
461
462 #[unsafe(method(new))]
463 #[unsafe(method_family = new)]
464 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
465 );
466}
467
468#[cfg(all(feature = "NSResponder", feature = "NSView"))]
470impl NSView {
471 extern_methods!(
472 #[unsafe(method(enclosingMenuItem))]
473 #[unsafe(method_family = none)]
474 pub fn enclosingMenuItem(&self) -> Option<Retained<NSMenuItem>>;
475 );
476}
477
478extern "C" {
479 #[cfg(feature = "NSUserInterfaceItemIdentification")]
481 pub static NSMenuItemImportFromDeviceIdentifier: &'static NSUserInterfaceItemIdentifier;
482}
483
484impl NSMenuItem {
486 extern_methods!(
487 #[deprecated]
488 #[unsafe(method(setMnemonicLocation:))]
489 #[unsafe(method_family = none)]
490 pub fn setMnemonicLocation(&self, location: NSUInteger);
491
492 #[deprecated]
493 #[unsafe(method(mnemonicLocation))]
494 #[unsafe(method_family = none)]
495 pub fn mnemonicLocation(&self) -> NSUInteger;
496
497 #[deprecated]
498 #[unsafe(method(mnemonic))]
499 #[unsafe(method_family = none)]
500 pub fn mnemonic(&self) -> Option<Retained<NSString>>;
501
502 #[deprecated]
503 #[unsafe(method(setTitleWithMnemonic:))]
504 #[unsafe(method_family = none)]
505 pub fn setTitleWithMnemonic(&self, string_with_ampersand: &NSString);
506 );
507}