objc2_app_kit/generated/
NSMenu.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// When set as a value on `NSMenu.presentationStyle`, determines how
13/// the given menu is presented.
14///
15/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenupresentationstyle?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct NSMenuPresentationStyle(pub NSInteger);
20impl NSMenuPresentationStyle {
21    /// The default presentation style. Typically means the menu will
22    /// be presented as either a popup or pulldown menu, based on the
23    /// context.
24    #[doc(alias = "NSMenuPresentationStyleRegular")]
25    pub const Regular: Self = Self(0);
26    /// The menu marked as palette is to be displayed in place of the
27    /// menu item presenting it, with its items aligned horizontally.
28    #[doc(alias = "NSMenuPresentationStylePalette")]
29    pub const Palette: Self = Self(1);
30}
31
32unsafe impl Encode for NSMenuPresentationStyle {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for NSMenuPresentationStyle {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40/// When set as a value on `NSMenu.selectionMode`, determines how the
41/// menu manages selection states of the menu items that belong to
42/// the same selection group.
43///
44/// This does not apply to menu items that have distinct
45/// target/action values.
46///
47/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenuselectionmode?language=objc)
48// NS_ENUM
49#[repr(transparent)]
50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
51pub struct NSMenuSelectionMode(pub NSInteger);
52impl NSMenuSelectionMode {
53    /// The menu will determine the appropriate selection mode based
54    /// on the context and its contents.
55    #[doc(alias = "NSMenuSelectionModeAutomatic")]
56    pub const Automatic: Self = Self(0);
57    /// The user will be allowed to select at most one menu item in
58    /// the same selection group at a time. A change in selection
59    /// will deselect any previously selected item.
60    #[doc(alias = "NSMenuSelectionModeSelectOne")]
61    pub const SelectOne: Self = Self(1);
62    /// The user can select multiple items in the menu. A change in
63    /// selection will not automatically deselect any previously
64    /// selected item in the same selection group.
65    #[doc(alias = "NSMenuSelectionModeSelectAny")]
66    pub const SelectAny: Self = Self(2);
67}
68
69unsafe impl Encode for NSMenuSelectionMode {
70    const ENCODING: Encoding = NSInteger::ENCODING;
71}
72
73unsafe impl RefEncode for NSMenuSelectionMode {
74    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
75}
76
77extern_class!(
78    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenu?language=objc)
79    #[unsafe(super(NSObject))]
80    #[thread_kind = MainThreadOnly]
81    #[derive(Debug, PartialEq, Eq, Hash)]
82    pub struct NSMenu;
83);
84
85#[cfg(feature = "NSAccessibilityProtocols")]
86extern_conformance!(
87    unsafe impl NSAccessibility for NSMenu {}
88);
89
90#[cfg(feature = "NSAccessibilityProtocols")]
91extern_conformance!(
92    unsafe impl NSAccessibilityElementProtocol for NSMenu {}
93);
94
95#[cfg(feature = "NSAppearance")]
96extern_conformance!(
97    unsafe impl NSAppearanceCustomization for NSMenu {}
98);
99
100extern_conformance!(
101    unsafe impl NSCoding for NSMenu {}
102);
103
104extern_conformance!(
105    unsafe impl NSCopying for NSMenu {}
106);
107
108unsafe impl CopyingHelper for NSMenu {
109    type Result = Self;
110}
111
112extern_conformance!(
113    unsafe impl NSObjectProtocol for NSMenu {}
114);
115
116#[cfg(feature = "NSUserInterfaceItemIdentification")]
117extern_conformance!(
118    unsafe impl NSUserInterfaceItemIdentification for NSMenu {}
119);
120
121impl NSMenu {
122    extern_methods!(
123        #[unsafe(method(initWithTitle:))]
124        #[unsafe(method_family = init)]
125        pub unsafe fn initWithTitle(this: Allocated<Self>, title: &NSString) -> Retained<Self>;
126
127        #[unsafe(method(initWithCoder:))]
128        #[unsafe(method_family = init)]
129        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
130
131        #[unsafe(method(title))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn title(&self) -> Retained<NSString>;
134
135        /// Setter for [`title`][Self::title].
136        #[unsafe(method(setTitle:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setTitle(&self, title: &NSString);
139
140        #[cfg(all(feature = "NSEvent", feature = "NSResponder", feature = "NSView"))]
141        #[unsafe(method(popUpContextMenu:withEvent:forView:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn popUpContextMenu_withEvent_forView(
144            menu: &NSMenu,
145            event: &NSEvent,
146            view: &NSView,
147        );
148
149        #[cfg(all(
150            feature = "NSEvent",
151            feature = "NSFont",
152            feature = "NSResponder",
153            feature = "NSView"
154        ))]
155        #[unsafe(method(popUpContextMenu:withEvent:forView:withFont:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn popUpContextMenu_withEvent_forView_withFont(
158            menu: &NSMenu,
159            event: &NSEvent,
160            view: &NSView,
161            font: Option<&NSFont>,
162        );
163
164        #[cfg(all(feature = "NSMenuItem", feature = "NSResponder", feature = "NSView"))]
165        #[unsafe(method(popUpMenuPositioningItem:atLocation:inView:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn popUpMenuPositioningItem_atLocation_inView(
168            &self,
169            item: Option<&NSMenuItem>,
170            location: NSPoint,
171            view: Option<&NSView>,
172        ) -> bool;
173
174        #[unsafe(method(setMenuBarVisible:))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn setMenuBarVisible(visible: bool, mtm: MainThreadMarker);
177
178        #[unsafe(method(menuBarVisible))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn menuBarVisible(mtm: MainThreadMarker) -> bool;
181
182        #[unsafe(method(supermenu))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn supermenu(&self) -> Option<Retained<NSMenu>>;
185
186        /// Setter for [`supermenu`][Self::supermenu].
187        #[unsafe(method(setSupermenu:))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn setSupermenu(&self, supermenu: Option<&NSMenu>);
190
191        #[cfg(feature = "NSMenuItem")]
192        #[unsafe(method(insertItem:atIndex:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn insertItem_atIndex(&self, new_item: &NSMenuItem, index: NSInteger);
195
196        #[cfg(feature = "NSMenuItem")]
197        #[unsafe(method(addItem:))]
198        #[unsafe(method_family = none)]
199        pub fn addItem(&self, new_item: &NSMenuItem);
200
201        #[cfg(feature = "NSMenuItem")]
202        #[unsafe(method(insertItemWithTitle:action:keyEquivalent:atIndex:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn insertItemWithTitle_action_keyEquivalent_atIndex(
205            &self,
206            string: &NSString,
207            selector: Option<Sel>,
208            char_code: &NSString,
209            index: NSInteger,
210        ) -> Retained<NSMenuItem>;
211
212        #[cfg(feature = "NSMenuItem")]
213        #[unsafe(method(addItemWithTitle:action:keyEquivalent:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn addItemWithTitle_action_keyEquivalent(
216            &self,
217            string: &NSString,
218            selector: Option<Sel>,
219            char_code: &NSString,
220        ) -> Retained<NSMenuItem>;
221
222        #[unsafe(method(removeItemAtIndex:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn removeItemAtIndex(&self, index: NSInteger);
225
226        #[cfg(feature = "NSMenuItem")]
227        #[unsafe(method(removeItem:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn removeItem(&self, item: &NSMenuItem);
230
231        #[cfg(feature = "NSMenuItem")]
232        #[unsafe(method(setSubmenu:forItem:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setSubmenu_forItem(&self, menu: Option<&NSMenu>, item: &NSMenuItem);
235
236        #[unsafe(method(removeAllItems))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn removeAllItems(&self);
239
240        #[cfg(feature = "NSMenuItem")]
241        #[unsafe(method(itemArray))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;
244
245        #[cfg(feature = "NSMenuItem")]
246        /// Setter for [`itemArray`][Self::itemArray].
247        #[unsafe(method(setItemArray:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setItemArray(&self, item_array: &NSArray<NSMenuItem>);
250
251        #[unsafe(method(numberOfItems))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn numberOfItems(&self) -> NSInteger;
254
255        #[cfg(feature = "NSMenuItem")]
256        #[unsafe(method(itemAtIndex:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;
259
260        #[cfg(feature = "NSMenuItem")]
261        #[unsafe(method(indexOfItem:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;
264
265        #[unsafe(method(indexOfItemWithTitle:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;
268
269        #[unsafe(method(indexOfItemWithTag:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;
272
273        #[unsafe(method(indexOfItemWithRepresentedObject:))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn indexOfItemWithRepresentedObject(
276            &self,
277            object: Option<&AnyObject>,
278        ) -> NSInteger;
279
280        #[unsafe(method(indexOfItemWithSubmenu:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn indexOfItemWithSubmenu(&self, submenu: Option<&NSMenu>) -> NSInteger;
283
284        #[unsafe(method(indexOfItemWithTarget:andAction:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn indexOfItemWithTarget_andAction(
287            &self,
288            target: Option<&AnyObject>,
289            action_selector: Option<Sel>,
290        ) -> NSInteger;
291
292        #[cfg(feature = "NSMenuItem")]
293        #[unsafe(method(itemWithTitle:))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;
296
297        #[cfg(feature = "NSMenuItem")]
298        #[unsafe(method(itemWithTag:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn itemWithTag(&self, tag: NSInteger) -> Option<Retained<NSMenuItem>>;
301
302        #[unsafe(method(autoenablesItems))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn autoenablesItems(&self) -> bool;
305
306        /// Setter for [`autoenablesItems`][Self::autoenablesItems].
307        #[unsafe(method(setAutoenablesItems:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn setAutoenablesItems(&self, autoenables_items: bool);
310
311        #[unsafe(method(update))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn update(&self);
314
315        #[cfg(feature = "NSEvent")]
316        #[unsafe(method(performKeyEquivalent:))]
317        #[unsafe(method_family = none)]
318        pub unsafe fn performKeyEquivalent(&self, event: &NSEvent) -> bool;
319
320        #[cfg(feature = "NSMenuItem")]
321        #[unsafe(method(itemChanged:))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn itemChanged(&self, item: &NSMenuItem);
324
325        #[unsafe(method(performActionForItemAtIndex:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn performActionForItemAtIndex(&self, index: NSInteger);
328
329        #[unsafe(method(delegate))]
330        #[unsafe(method_family = none)]
331        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSMenuDelegate>>>;
332
333        /// This is a [weak property][objc2::topics::weak_property].
334        /// Setter for [`delegate`][Self::delegate].
335        #[unsafe(method(setDelegate:))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSMenuDelegate>>);
338
339        #[cfg(feature = "objc2-core-foundation")]
340        #[unsafe(method(menuBarHeight))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn menuBarHeight(&self) -> CGFloat;
343
344        #[unsafe(method(cancelTracking))]
345        #[unsafe(method_family = none)]
346        pub unsafe fn cancelTracking(&self);
347
348        #[unsafe(method(cancelTrackingWithoutAnimation))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn cancelTrackingWithoutAnimation(&self);
351
352        #[cfg(feature = "NSMenuItem")]
353        #[unsafe(method(highlightedItem))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn highlightedItem(&self) -> Option<Retained<NSMenuItem>>;
356
357        #[cfg(feature = "objc2-core-foundation")]
358        #[unsafe(method(minimumWidth))]
359        #[unsafe(method_family = none)]
360        pub unsafe fn minimumWidth(&self) -> CGFloat;
361
362        #[cfg(feature = "objc2-core-foundation")]
363        /// Setter for [`minimumWidth`][Self::minimumWidth].
364        #[unsafe(method(setMinimumWidth:))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn setMinimumWidth(&self, minimum_width: CGFloat);
367
368        #[unsafe(method(size))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn size(&self) -> NSSize;
371
372        #[cfg(feature = "NSFont")]
373        #[unsafe(method(font))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn font(&self) -> Option<Retained<NSFont>>;
376
377        #[cfg(feature = "NSFont")]
378        /// Setter for [`font`][Self::font].
379        #[unsafe(method(setFont:))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn setFont(&self, font: Option<&NSFont>);
382
383        #[unsafe(method(allowsContextMenuPlugIns))]
384        #[unsafe(method_family = none)]
385        pub unsafe fn allowsContextMenuPlugIns(&self) -> bool;
386
387        /// Setter for [`allowsContextMenuPlugIns`][Self::allowsContextMenuPlugIns].
388        #[unsafe(method(setAllowsContextMenuPlugIns:))]
389        #[unsafe(method_family = none)]
390        pub unsafe fn setAllowsContextMenuPlugIns(&self, allows_context_menu_plug_ins: bool);
391
392        #[unsafe(method(automaticallyInsertsWritingToolsItems))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn automaticallyInsertsWritingToolsItems(&self) -> bool;
395
396        /// Setter for [`automaticallyInsertsWritingToolsItems`][Self::automaticallyInsertsWritingToolsItems].
397        #[unsafe(method(setAutomaticallyInsertsWritingToolsItems:))]
398        #[unsafe(method_family = none)]
399        pub unsafe fn setAutomaticallyInsertsWritingToolsItems(
400            &self,
401            automatically_inserts_writing_tools_items: bool,
402        );
403
404        #[unsafe(method(showsStateColumn))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn showsStateColumn(&self) -> bool;
407
408        /// Setter for [`showsStateColumn`][Self::showsStateColumn].
409        #[unsafe(method(setShowsStateColumn:))]
410        #[unsafe(method_family = none)]
411        pub unsafe fn setShowsStateColumn(&self, shows_state_column: bool);
412
413        #[cfg(feature = "NSUserInterfaceLayout")]
414        #[unsafe(method(userInterfaceLayoutDirection))]
415        #[unsafe(method_family = none)]
416        pub unsafe fn userInterfaceLayoutDirection(&self) -> NSUserInterfaceLayoutDirection;
417
418        #[cfg(feature = "NSUserInterfaceLayout")]
419        /// Setter for [`userInterfaceLayoutDirection`][Self::userInterfaceLayoutDirection].
420        #[unsafe(method(setUserInterfaceLayoutDirection:))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn setUserInterfaceLayoutDirection(
423            &self,
424            user_interface_layout_direction: NSUserInterfaceLayoutDirection,
425        );
426    );
427}
428
429/// Methods declared on superclass `NSObject`.
430impl NSMenu {
431    extern_methods!(
432        #[unsafe(method(init))]
433        #[unsafe(method_family = init)]
434        pub fn init(this: Allocated<Self>) -> Retained<Self>;
435
436        #[unsafe(method(new))]
437        #[unsafe(method_family = new)]
438        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
439    );
440}
441
442/// NSPaletteMenus.
443impl NSMenu {
444    extern_methods!(
445        #[cfg(all(feature = "NSColor", feature = "block2"))]
446        /// Creates a palette menu displaying user-selectable color
447        /// tags using the provided array of colors and optional titles.
448        ///
449        /// Returns: An autoconfigured palette menu.
450        #[unsafe(method(paletteMenuWithColors:titles:selectionHandler:))]
451        #[unsafe(method_family = none)]
452        pub unsafe fn paletteMenuWithColors_titles_selectionHandler(
453            colors: &NSArray<NSColor>,
454            item_titles: &NSArray<NSString>,
455            on_selection_change: Option<&block2::DynBlock<dyn Fn(NonNull<NSMenu>)>>,
456            mtm: MainThreadMarker,
457        ) -> Retained<Self>;
458
459        #[cfg(all(feature = "NSColor", feature = "NSImage", feature = "block2"))]
460        /// Creates an palette menu displaying user-selectable color tags
461        /// using the provided template image, tinted using the specified
462        /// array of colors.
463        ///
464        /// Optionally allows observing changes to the selection state in
465        /// the compact menu. The block is invoked after the selection
466        /// has been updated. Currently selected items can be retrieved
467        /// from the `selectedItems` property.
468        ///
469        ///
470        /// Returns: An autoconfigured palette menu.
471        #[unsafe(method(paletteMenuWithColors:titles:templateImage:selectionHandler:))]
472        #[unsafe(method_family = none)]
473        pub unsafe fn paletteMenuWithColors_titles_templateImage_selectionHandler(
474            colors: &NSArray<NSColor>,
475            item_titles: &NSArray<NSString>,
476            image: &NSImage,
477            on_selection_change: Option<&block2::DynBlock<dyn Fn(NonNull<NSMenu>)>>,
478            mtm: MainThreadMarker,
479        ) -> Retained<Self>;
480
481        /// The presentation style of the menu.
482        ///
483        ///
484        /// Note: This property is not respected if the menu is the main
485        /// menu of the app.
486        #[unsafe(method(presentationStyle))]
487        #[unsafe(method_family = none)]
488        pub unsafe fn presentationStyle(&self) -> NSMenuPresentationStyle;
489
490        /// Setter for [`presentationStyle`][Self::presentationStyle].
491        #[unsafe(method(setPresentationStyle:))]
492        #[unsafe(method_family = none)]
493        pub unsafe fn setPresentationStyle(&self, presentation_style: NSMenuPresentationStyle);
494
495        /// The selection mode of the menu.
496        ///
497        /// Note the selection mode only has effect on menu items that
498        /// belong to the same selection group. A selection group consists
499        /// of the items with the same target/action.
500        #[unsafe(method(selectionMode))]
501        #[unsafe(method_family = none)]
502        pub unsafe fn selectionMode(&self) -> NSMenuSelectionMode;
503
504        /// Setter for [`selectionMode`][Self::selectionMode].
505        #[unsafe(method(setSelectionMode:))]
506        #[unsafe(method_family = none)]
507        pub unsafe fn setSelectionMode(&self, selection_mode: NSMenuSelectionMode);
508
509        #[cfg(feature = "NSMenuItem")]
510        /// The menu items that are selected.
511        ///
512        /// An item is selected when its state is `NSControl.StateValue.on`.
513        ///
514        ///
515        /// Note: This property is settable. Setting `selectedItems` will
516        /// select any items that are contained in the provided array, and
517        /// deselect any previously selected items that are not in the array.
518        #[unsafe(method(selectedItems))]
519        #[unsafe(method_family = none)]
520        pub unsafe fn selectedItems(&self) -> Retained<NSArray<NSMenuItem>>;
521
522        #[cfg(feature = "NSMenuItem")]
523        /// Setter for [`selectedItems`][Self::selectedItems].
524        #[unsafe(method(setSelectedItems:))]
525        #[unsafe(method_family = none)]
526        pub unsafe fn setSelectedItems(&self, selected_items: &NSArray<NSMenuItem>);
527    );
528}
529
530/// NSSubmenuAction.
531impl NSMenu {
532    extern_methods!(
533        #[unsafe(method(submenuAction:))]
534        #[unsafe(method_family = none)]
535        pub unsafe fn submenuAction(&self, sender: Option<&AnyObject>);
536    );
537}
538
539extern_protocol!(
540    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenuitemvalidation?language=objc)
541    pub unsafe trait NSMenuItemValidation: NSObjectProtocol + MainThreadOnly {
542        #[cfg(feature = "NSMenuItem")]
543        #[unsafe(method(validateMenuItem:))]
544        #[unsafe(method_family = none)]
545        unsafe fn validateMenuItem(&self, menu_item: &NSMenuItem) -> bool;
546    }
547);
548
549extern_protocol!(
550    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenudelegate?language=objc)
551    pub unsafe trait NSMenuDelegate: NSObjectProtocol + MainThreadOnly {
552        #[optional]
553        #[unsafe(method(menuNeedsUpdate:))]
554        #[unsafe(method_family = none)]
555        unsafe fn menuNeedsUpdate(&self, menu: &NSMenu);
556
557        #[optional]
558        #[unsafe(method(numberOfItemsInMenu:))]
559        #[unsafe(method_family = none)]
560        unsafe fn numberOfItemsInMenu(&self, menu: &NSMenu) -> NSInteger;
561
562        #[cfg(feature = "NSMenuItem")]
563        #[optional]
564        #[unsafe(method(menu:updateItem:atIndex:shouldCancel:))]
565        #[unsafe(method_family = none)]
566        unsafe fn menu_updateItem_atIndex_shouldCancel(
567            &self,
568            menu: &NSMenu,
569            item: &NSMenuItem,
570            index: NSInteger,
571            should_cancel: bool,
572        ) -> bool;
573
574        #[optional]
575        #[unsafe(method(menuWillOpen:))]
576        #[unsafe(method_family = none)]
577        unsafe fn menuWillOpen(&self, menu: &NSMenu);
578
579        #[optional]
580        #[unsafe(method(menuDidClose:))]
581        #[unsafe(method_family = none)]
582        unsafe fn menuDidClose(&self, menu: &NSMenu);
583
584        #[cfg(feature = "NSMenuItem")]
585        #[optional]
586        #[unsafe(method(menu:willHighlightItem:))]
587        #[unsafe(method_family = none)]
588        unsafe fn menu_willHighlightItem(&self, menu: &NSMenu, item: Option<&NSMenuItem>);
589
590        #[cfg(feature = "NSScreen")]
591        #[optional]
592        #[unsafe(method(confinementRectForMenu:onScreen:))]
593        #[unsafe(method_family = none)]
594        unsafe fn confinementRectForMenu_onScreen(
595            &self,
596            menu: &NSMenu,
597            screen: Option<&NSScreen>,
598        ) -> NSRect;
599    }
600);
601
602/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenuproperties?language=objc)
603// NS_OPTIONS
604#[repr(transparent)]
605#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
606pub struct NSMenuProperties(pub NSUInteger);
607bitflags::bitflags! {
608    impl NSMenuProperties: NSUInteger {
609        #[doc(alias = "NSMenuPropertyItemTitle")]
610        const ItemTitle = 1<<0;
611        #[doc(alias = "NSMenuPropertyItemAttributedTitle")]
612        const ItemAttributedTitle = 1<<1;
613        #[doc(alias = "NSMenuPropertyItemKeyEquivalent")]
614        const ItemKeyEquivalent = 1<<2;
615        #[doc(alias = "NSMenuPropertyItemImage")]
616        const ItemImage = 1<<3;
617        #[doc(alias = "NSMenuPropertyItemEnabled")]
618        const ItemEnabled = 1<<4;
619        #[doc(alias = "NSMenuPropertyItemAccessibilityDescription")]
620        const ItemAccessibilityDescription = 1<<5;
621    }
622}
623
624unsafe impl Encode for NSMenuProperties {
625    const ENCODING: Encoding = NSUInteger::ENCODING;
626}
627
628unsafe impl RefEncode for NSMenuProperties {
629    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
630}
631
632/// NSMenuPropertiesToUpdate.
633impl NSMenu {
634    extern_methods!(
635        #[unsafe(method(propertiesToUpdate))]
636        #[unsafe(method_family = none)]
637        pub unsafe fn propertiesToUpdate(&self) -> NSMenuProperties;
638    );
639}
640
641extern "C" {
642    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenuwillsendactionnotification?language=objc)
643    pub static NSMenuWillSendActionNotification: &'static NSNotificationName;
644}
645
646extern "C" {
647    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenudidsendactionnotification?language=objc)
648    pub static NSMenuDidSendActionNotification: &'static NSNotificationName;
649}
650
651extern "C" {
652    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenudidadditemnotification?language=objc)
653    pub static NSMenuDidAddItemNotification: &'static NSNotificationName;
654}
655
656extern "C" {
657    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenudidremoveitemnotification?language=objc)
658    pub static NSMenuDidRemoveItemNotification: &'static NSNotificationName;
659}
660
661extern "C" {
662    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenudidchangeitemnotification?language=objc)
663    pub static NSMenuDidChangeItemNotification: &'static NSNotificationName;
664}
665
666extern "C" {
667    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenudidbegintrackingnotification?language=objc)
668    pub static NSMenuDidBeginTrackingNotification: &'static NSNotificationName;
669}
670
671extern "C" {
672    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmenudidendtrackingnotification?language=objc)
673    pub static NSMenuDidEndTrackingNotification: &'static NSNotificationName;
674}
675
676/// NSDeprecated.
677impl NSMenu {
678    extern_methods!(
679        #[deprecated]
680        #[unsafe(method(setMenuRepresentation:))]
681        #[unsafe(method_family = none)]
682        pub unsafe fn setMenuRepresentation(&self, menu_rep: Option<&AnyObject>);
683
684        #[deprecated]
685        #[unsafe(method(menuRepresentation))]
686        #[unsafe(method_family = none)]
687        pub unsafe fn menuRepresentation(&self) -> Option<Retained<AnyObject>>;
688
689        #[deprecated]
690        #[unsafe(method(setContextMenuRepresentation:))]
691        #[unsafe(method_family = none)]
692        pub unsafe fn setContextMenuRepresentation(&self, menu_rep: Option<&AnyObject>);
693
694        #[deprecated]
695        #[unsafe(method(contextMenuRepresentation))]
696        #[unsafe(method_family = none)]
697        pub unsafe fn contextMenuRepresentation(&self) -> Option<Retained<AnyObject>>;
698
699        #[deprecated]
700        #[unsafe(method(setTearOffMenuRepresentation:))]
701        #[unsafe(method_family = none)]
702        pub unsafe fn setTearOffMenuRepresentation(&self, menu_rep: Option<&AnyObject>);
703
704        #[deprecated]
705        #[unsafe(method(tearOffMenuRepresentation))]
706        #[unsafe(method_family = none)]
707        pub unsafe fn tearOffMenuRepresentation(&self) -> Option<Retained<AnyObject>>;
708
709        #[deprecated]
710        #[unsafe(method(menuZone))]
711        #[unsafe(method_family = none)]
712        pub unsafe fn menuZone(mtm: MainThreadMarker) -> *mut NSZone;
713
714        #[deprecated]
715        #[unsafe(method(setMenuZone:))]
716        #[unsafe(method_family = none)]
717        pub unsafe fn setMenuZone(zone: *mut NSZone, mtm: MainThreadMarker);
718
719        #[deprecated]
720        #[unsafe(method(attachedMenu))]
721        #[unsafe(method_family = none)]
722        pub unsafe fn attachedMenu(&self) -> Option<Retained<NSMenu>>;
723
724        #[deprecated]
725        #[unsafe(method(isAttached))]
726        #[unsafe(method_family = none)]
727        pub unsafe fn isAttached(&self) -> bool;
728
729        #[deprecated]
730        #[unsafe(method(sizeToFit))]
731        #[unsafe(method_family = none)]
732        pub unsafe fn sizeToFit(&self);
733
734        #[deprecated]
735        #[unsafe(method(locationForSubmenu:))]
736        #[unsafe(method_family = none)]
737        pub unsafe fn locationForSubmenu(&self, submenu: Option<&NSMenu>) -> NSPoint;
738
739        #[deprecated]
740        #[unsafe(method(menuChangedMessagesEnabled))]
741        #[unsafe(method_family = none)]
742        pub unsafe fn menuChangedMessagesEnabled(&self) -> bool;
743
744        /// Setter for [`menuChangedMessagesEnabled`][Self::menuChangedMessagesEnabled].
745        #[deprecated]
746        #[unsafe(method(setMenuChangedMessagesEnabled:))]
747        #[unsafe(method_family = none)]
748        pub unsafe fn setMenuChangedMessagesEnabled(&self, menu_changed_messages_enabled: bool);
749
750        #[cfg(feature = "NSEvent")]
751        #[deprecated]
752        #[unsafe(method(helpRequested:))]
753        #[unsafe(method_family = none)]
754        pub unsafe fn helpRequested(&self, event_ptr: &NSEvent);
755
756        #[deprecated]
757        #[unsafe(method(isTornOff))]
758        #[unsafe(method_family = none)]
759        pub unsafe fn isTornOff(&self) -> bool;
760    );
761}