objc2_app_kit/generated/
NSPopUpButton.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/appkit/nspopupbutton?language=objc)
12    #[unsafe(super(NSButton, NSControl, NSView, NSResponder, NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    #[cfg(all(
15        feature = "NSButton",
16        feature = "NSControl",
17        feature = "NSResponder",
18        feature = "NSView"
19    ))]
20    pub struct NSPopUpButton;
21);
22
23#[cfg(all(
24    feature = "NSAccessibilityProtocols",
25    feature = "NSButton",
26    feature = "NSControl",
27    feature = "NSResponder",
28    feature = "NSView"
29))]
30extern_conformance!(
31    unsafe impl NSAccessibility for NSPopUpButton {}
32);
33
34#[cfg(all(
35    feature = "NSAccessibilityProtocols",
36    feature = "NSButton",
37    feature = "NSControl",
38    feature = "NSResponder",
39    feature = "NSView"
40))]
41extern_conformance!(
42    unsafe impl NSAccessibilityButton for NSPopUpButton {}
43);
44
45#[cfg(all(
46    feature = "NSAccessibilityProtocols",
47    feature = "NSButton",
48    feature = "NSControl",
49    feature = "NSResponder",
50    feature = "NSView"
51))]
52extern_conformance!(
53    unsafe impl NSAccessibilityElementProtocol for NSPopUpButton {}
54);
55
56#[cfg(all(
57    feature = "NSAnimation",
58    feature = "NSButton",
59    feature = "NSControl",
60    feature = "NSResponder",
61    feature = "NSView"
62))]
63extern_conformance!(
64    unsafe impl NSAnimatablePropertyContainer for NSPopUpButton {}
65);
66
67#[cfg(all(
68    feature = "NSAppearance",
69    feature = "NSButton",
70    feature = "NSControl",
71    feature = "NSResponder",
72    feature = "NSView"
73))]
74extern_conformance!(
75    unsafe impl NSAppearanceCustomization for NSPopUpButton {}
76);
77
78#[cfg(all(
79    feature = "NSButton",
80    feature = "NSControl",
81    feature = "NSResponder",
82    feature = "NSView"
83))]
84extern_conformance!(
85    unsafe impl NSCoding for NSPopUpButton {}
86);
87
88#[cfg(all(
89    feature = "NSButton",
90    feature = "NSControl",
91    feature = "NSDragging",
92    feature = "NSResponder",
93    feature = "NSView"
94))]
95extern_conformance!(
96    unsafe impl NSDraggingDestination for NSPopUpButton {}
97);
98
99#[cfg(all(
100    feature = "NSButton",
101    feature = "NSControl",
102    feature = "NSResponder",
103    feature = "NSView"
104))]
105extern_conformance!(
106    unsafe impl NSObjectProtocol for NSPopUpButton {}
107);
108
109#[cfg(all(
110    feature = "NSButton",
111    feature = "NSControl",
112    feature = "NSResponder",
113    feature = "NSUserInterfaceCompression",
114    feature = "NSView"
115))]
116extern_conformance!(
117    unsafe impl NSUserInterfaceCompression for NSPopUpButton {}
118);
119
120#[cfg(all(
121    feature = "NSButton",
122    feature = "NSControl",
123    feature = "NSResponder",
124    feature = "NSUserInterfaceItemIdentification",
125    feature = "NSView"
126))]
127extern_conformance!(
128    unsafe impl NSUserInterfaceItemIdentification for NSPopUpButton {}
129);
130
131#[cfg(all(
132    feature = "NSButton",
133    feature = "NSControl",
134    feature = "NSResponder",
135    feature = "NSUserInterfaceValidation",
136    feature = "NSView"
137))]
138extern_conformance!(
139    unsafe impl NSUserInterfaceValidations for NSPopUpButton {}
140);
141
142#[cfg(all(
143    feature = "NSButton",
144    feature = "NSControl",
145    feature = "NSResponder",
146    feature = "NSView"
147))]
148impl NSPopUpButton {
149    extern_methods!(
150        #[cfg(feature = "NSMenu")]
151        /// Creates a standard pop-up button with a menu, target, and action.
152        ///
153        /// Parameter `menu`: A menu presented by the pop-up button, containing items that the user can choose between.
154        ///
155        /// Parameter `target`: The target object that receives action messages from the control.
156        ///
157        /// Parameter `action`: The action message sent by the control.
158        ///
159        /// If `menu` is non-empty, the pop-up button uses the first item for its initial selection.
160        ///
161        /// Returns: An initialized pop-up button object.
162        #[unsafe(method(popUpButtonWithMenu:target:action:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn popUpButtonWithMenu_target_action(
165            menu: &NSMenu,
166            target: Option<&AnyObject>,
167            action: Option<Sel>,
168        ) -> Retained<Self>;
169
170        #[cfg(feature = "NSMenu")]
171        /// Creates a standard pull-down button with a title and menu.
172        ///
173        /// Parameter `title`: The localized title string that is displayed on the button.
174        ///
175        /// Parameter `menu`: The pull-down menu to present when interacting with the button.
176        ///
177        /// Pull-down buttons created using this method have the `usesItemFromMenu` property set to `NO`.
178        ///
179        /// Returns: An initialized pull-down button object.
180        #[unsafe(method(pullDownButtonWithTitle:menu:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn pullDownButtonWithTitle_menu(
183            title: &NSString,
184            menu: &NSMenu,
185        ) -> Retained<Self>;
186
187        #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
188        /// Creates a standard pull-down button with an image and menu.
189        ///
190        /// Parameter `image`: The icon that is displayed on the button.
191        ///
192        /// Parameter `menu`: The pull-down menu to present when interacting with the button.
193        ///
194        /// Pull-down buttons created using this method have the `usesItemFromMenu` property set to `NO`.
195        ///
196        /// Returns: An initialized pull-down button object.
197        #[unsafe(method(pullDownButtonWithImage:menu:))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn pullDownButtonWithImage_menu(
200            image: &NSImage,
201            menu: &NSMenu,
202        ) -> Retained<Self>;
203
204        #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
205        /// Creates a standard pull-down button with a title, image, and menu.
206        ///
207        /// Parameter `title`: The localized title string that is displayed on the button.
208        ///
209        /// Parameter `image`: The icon that is displayed on the button.
210        ///
211        /// Parameter `menu`: The pull-down menu to present when interacting with the button.
212        ///
213        /// Pull-down buttons created using this method have the `usesItemFromMenu` property set to `NO`.
214        ///
215        /// Returns: An initialized pull-down button object.
216        #[unsafe(method(pullDownButtonWithTitle:image:menu:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn pullDownButtonWithTitle_image_menu(
219            title: &NSString,
220            image: &NSImage,
221            menu: &NSMenu,
222        ) -> Retained<Self>;
223
224        #[unsafe(method(initWithFrame:pullsDown:))]
225        #[unsafe(method_family = init)]
226        pub unsafe fn initWithFrame_pullsDown(
227            this: Allocated<Self>,
228            button_frame: NSRect,
229            flag: bool,
230        ) -> Retained<Self>;
231
232        #[cfg(feature = "NSMenu")]
233        /// The menu that is presented by the popup button. This overrides the inherited NSView property and replaces NSView's standard context menu behavior.
234        #[unsafe(method(menu))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn menu(&self) -> Option<Retained<NSMenu>>;
237
238        #[cfg(feature = "NSMenu")]
239        /// Setter for [`menu`][Self::menu].
240        #[unsafe(method(setMenu:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);
243
244        /// When the value of this property is `YES` the button adopts 'pull-down' behavior, displaying static button contents and presenting its menu at the edge of the button. When the value of this property is `NO` the button behaves as a popup, displaying the currently-selected menu item and presenting its menu above the button, positioning the selected menu item to match the button's contents.
245        #[unsafe(method(pullsDown))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn pullsDown(&self) -> bool;
248
249        /// Setter for [`pullsDown`][Self::pullsDown].
250        #[unsafe(method(setPullsDown:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setPullsDown(&self, pulls_down: bool);
253
254        /// When the value of this property is `YES`, the popup button automatically enables and disables its menu items according to the `NSMenuValidation` protocol prior to user interaction.
255        #[unsafe(method(autoenablesItems))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn autoenablesItems(&self) -> bool;
258
259        /// Setter for [`autoenablesItems`][Self::autoenablesItems].
260        #[unsafe(method(setAutoenablesItems:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn setAutoenablesItems(&self, autoenables_items: bool);
263
264        /// For pull-down buttons and for popups under severe screen position restrictions, this property specifies the edge of the control that the menu should present from.
265        #[unsafe(method(preferredEdge))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn preferredEdge(&self) -> NSRectEdge;
268
269        /// Setter for [`preferredEdge`][Self::preferredEdge].
270        #[unsafe(method(setPreferredEdge:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn setPreferredEdge(&self, preferred_edge: NSRectEdge);
273
274        /// When `usesItemFromMenu` is `YES`, a pull-down button uses the title of the first menu item and hides the first menu item. A pop-up button uses the title of the currently selected menu. The default value is `YES`.
275        #[unsafe(method(usesItemFromMenu))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn usesItemFromMenu(&self) -> bool;
278
279        /// Setter for [`usesItemFromMenu`][Self::usesItemFromMenu].
280        #[unsafe(method(setUsesItemFromMenu:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn setUsesItemFromMenu(&self, uses_item_from_menu: bool);
283
284        /// When the value of this property is `YES`, the selected menu item's `state` is set to `NSControlStateValueOn`. When the value of this property is `NO`, the menu item's `state` is not changed. When this property changes, the `state` of the currently selected item is updated appropriately. This property is ignored for pull-down buttons.
285        #[unsafe(method(altersStateOfSelectedItem))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn altersStateOfSelectedItem(&self) -> bool;
288
289        /// Setter for [`altersStateOfSelectedItem`][Self::altersStateOfSelectedItem].
290        #[unsafe(method(setAltersStateOfSelectedItem:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn setAltersStateOfSelectedItem(&self, alters_state_of_selected_item: bool);
293
294        #[unsafe(method(addItemWithTitle:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn addItemWithTitle(&self, title: &NSString);
297
298        #[unsafe(method(addItemsWithTitles:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn addItemsWithTitles(&self, item_titles: &NSArray<NSString>);
301
302        #[unsafe(method(insertItemWithTitle:atIndex:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn insertItemWithTitle_atIndex(&self, title: &NSString, index: NSInteger);
305
306        #[unsafe(method(removeItemWithTitle:))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn removeItemWithTitle(&self, title: &NSString);
309
310        #[unsafe(method(removeItemAtIndex:))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn removeItemAtIndex(&self, index: NSInteger);
313
314        #[unsafe(method(removeAllItems))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn removeAllItems(&self);
317
318        #[cfg(feature = "NSMenuItem")]
319        #[unsafe(method(itemArray))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn itemArray(&self) -> Retained<NSArray<NSMenuItem>>;
322
323        #[unsafe(method(numberOfItems))]
324        #[unsafe(method_family = none)]
325        pub unsafe fn numberOfItems(&self) -> NSInteger;
326
327        #[cfg(feature = "NSMenuItem")]
328        #[unsafe(method(indexOfItem:))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn indexOfItem(&self, item: &NSMenuItem) -> NSInteger;
331
332        #[unsafe(method(indexOfItemWithTitle:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn indexOfItemWithTitle(&self, title: &NSString) -> NSInteger;
335
336        #[unsafe(method(indexOfItemWithTag:))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn indexOfItemWithTag(&self, tag: NSInteger) -> NSInteger;
339
340        #[unsafe(method(indexOfItemWithRepresentedObject:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn indexOfItemWithRepresentedObject(&self, obj: Option<&AnyObject>)
343            -> NSInteger;
344
345        #[unsafe(method(indexOfItemWithTarget:andAction:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn indexOfItemWithTarget_andAction(
348            &self,
349            target: Option<&AnyObject>,
350            action_selector: Option<Sel>,
351        ) -> NSInteger;
352
353        #[cfg(feature = "NSMenuItem")]
354        #[unsafe(method(itemAtIndex:))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn itemAtIndex(&self, index: NSInteger) -> Option<Retained<NSMenuItem>>;
357
358        #[cfg(feature = "NSMenuItem")]
359        #[unsafe(method(itemWithTitle:))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn itemWithTitle(&self, title: &NSString) -> Option<Retained<NSMenuItem>>;
362
363        #[cfg(feature = "NSMenuItem")]
364        #[unsafe(method(lastItem))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn lastItem(&self) -> Option<Retained<NSMenuItem>>;
367
368        #[cfg(feature = "NSMenuItem")]
369        #[unsafe(method(selectItem:))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn selectItem(&self, item: Option<&NSMenuItem>);
372
373        #[unsafe(method(selectItemAtIndex:))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn selectItemAtIndex(&self, index: NSInteger);
376
377        #[unsafe(method(selectItemWithTitle:))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn selectItemWithTitle(&self, title: &NSString);
380
381        #[unsafe(method(selectItemWithTag:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn selectItemWithTag(&self, tag: NSInteger) -> bool;
384
385        #[unsafe(method(setTitle:))]
386        #[unsafe(method_family = none)]
387        pub unsafe fn setTitle(&self, string: &NSString);
388
389        #[cfg(feature = "NSMenuItem")]
390        #[unsafe(method(selectedItem))]
391        #[unsafe(method_family = none)]
392        pub unsafe fn selectedItem(&self) -> Option<Retained<NSMenuItem>>;
393
394        #[unsafe(method(indexOfSelectedItem))]
395        #[unsafe(method_family = none)]
396        pub unsafe fn indexOfSelectedItem(&self) -> NSInteger;
397
398        #[unsafe(method(selectedTag))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn selectedTag(&self) -> NSInteger;
401
402        #[unsafe(method(synchronizeTitleAndSelectedItem))]
403        #[unsafe(method_family = none)]
404        pub unsafe fn synchronizeTitleAndSelectedItem(&self);
405
406        #[unsafe(method(itemTitleAtIndex:))]
407        #[unsafe(method_family = none)]
408        pub unsafe fn itemTitleAtIndex(&self, index: NSInteger) -> Retained<NSString>;
409
410        #[unsafe(method(itemTitles))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn itemTitles(&self) -> Retained<NSArray<NSString>>;
413
414        #[unsafe(method(titleOfSelectedItem))]
415        #[unsafe(method_family = none)]
416        pub unsafe fn titleOfSelectedItem(&self) -> Option<Retained<NSString>>;
417    );
418}
419
420/// Methods declared on superclass `NSButton`.
421#[cfg(all(
422    feature = "NSButton",
423    feature = "NSControl",
424    feature = "NSResponder",
425    feature = "NSView"
426))]
427impl NSPopUpButton {
428    extern_methods!(
429        #[cfg(feature = "NSImage")]
430        /// Creates a standard push button with a title and image.
431        ///
432        /// Parameter `title`: The localized title string that is displayed on the button.
433        ///
434        /// Parameter `image`: The image that is displayed alongside the title. In left-to-right localizations, the image is displayed to the left of the title. In right-to-left localizations, it is displayed to the right.
435        ///
436        /// Parameter `target`: The target object that receives action messages from the control.
437        ///
438        /// Parameter `action`: The action message sent by the control.
439        ///
440        /// Returns: An initialized button object.
441        #[unsafe(method(buttonWithTitle:image:target:action:))]
442        #[unsafe(method_family = none)]
443        pub unsafe fn buttonWithTitle_image_target_action(
444            title: &NSString,
445            image: &NSImage,
446            target: Option<&AnyObject>,
447            action: Option<Sel>,
448            mtm: MainThreadMarker,
449        ) -> Retained<Self>;
450
451        /// Creates a standard push button with the provided title.
452        ///
453        /// Parameter `title`: The localized title string that is displayed on the button.
454        ///
455        /// Parameter `target`: The target object that receives action messages from the control.
456        ///
457        /// Parameter `action`: The action message sent by the control.
458        ///
459        /// Returns: An initialized button object.
460        #[unsafe(method(buttonWithTitle:target:action:))]
461        #[unsafe(method_family = none)]
462        pub unsafe fn buttonWithTitle_target_action(
463            title: &NSString,
464            target: Option<&AnyObject>,
465            action: Option<Sel>,
466            mtm: MainThreadMarker,
467        ) -> Retained<Self>;
468
469        #[cfg(feature = "NSImage")]
470        /// Creates a standard push button with the provided image. Set the image's accessibilityDescription property to ensure accessibility for this control.
471        ///
472        /// Parameter `image`: The image to display in the body of the button.
473        ///
474        /// Parameter `target`: The target object that receives action messages from the control.
475        ///
476        /// Parameter `action`: The action message sent by the control.
477        ///
478        /// Returns: An initialized button object.
479        #[unsafe(method(buttonWithImage:target:action:))]
480        #[unsafe(method_family = none)]
481        pub unsafe fn buttonWithImage_target_action(
482            image: &NSImage,
483            target: Option<&AnyObject>,
484            action: Option<Sel>,
485            mtm: MainThreadMarker,
486        ) -> Retained<Self>;
487
488        /// Creates a standard checkbox with the provided title.
489        ///
490        /// Parameter `title`: The localized title string that is displayed alongside the checkbox.
491        ///
492        /// Parameter `target`: The target object that receives action messages from the control.
493        ///
494        /// Parameter `action`: The action message sent by the control.
495        ///
496        /// Returns: An initialized button object.
497        #[unsafe(method(checkboxWithTitle:target:action:))]
498        #[unsafe(method_family = none)]
499        pub unsafe fn checkboxWithTitle_target_action(
500            title: &NSString,
501            target: Option<&AnyObject>,
502            action: Option<Sel>,
503            mtm: MainThreadMarker,
504        ) -> Retained<Self>;
505
506        /// Creates a standard radio button with the provided title.
507        ///
508        /// Parameter `title`: The localized title string that is displayed alongside the radio button.
509        ///
510        /// Parameter `target`: The target object that receives action messages from the control.
511        ///
512        /// Parameter `action`: The action message sent by the control.
513        ///
514        /// Returns: An initialized button object.
515        #[unsafe(method(radioButtonWithTitle:target:action:))]
516        #[unsafe(method_family = none)]
517        pub unsafe fn radioButtonWithTitle_target_action(
518            title: &NSString,
519            target: Option<&AnyObject>,
520            action: Option<Sel>,
521            mtm: MainThreadMarker,
522        ) -> Retained<Self>;
523    );
524}
525
526/// Methods declared on superclass `NSControl`.
527#[cfg(all(
528    feature = "NSButton",
529    feature = "NSControl",
530    feature = "NSResponder",
531    feature = "NSView"
532))]
533impl NSPopUpButton {
534    extern_methods!(
535        #[unsafe(method(initWithFrame:))]
536        #[unsafe(method_family = init)]
537        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
538
539        #[unsafe(method(initWithCoder:))]
540        #[unsafe(method_family = init)]
541        pub unsafe fn initWithCoder(
542            this: Allocated<Self>,
543            coder: &NSCoder,
544        ) -> Option<Retained<Self>>;
545    );
546}
547
548/// Methods declared on superclass `NSResponder`.
549#[cfg(all(
550    feature = "NSButton",
551    feature = "NSControl",
552    feature = "NSResponder",
553    feature = "NSView"
554))]
555impl NSPopUpButton {
556    extern_methods!(
557        #[unsafe(method(init))]
558        #[unsafe(method_family = init)]
559        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
560    );
561}
562
563/// Methods declared on superclass `NSObject`.
564#[cfg(all(
565    feature = "NSButton",
566    feature = "NSControl",
567    feature = "NSResponder",
568    feature = "NSView"
569))]
570impl NSPopUpButton {
571    extern_methods!(
572        #[unsafe(method(new))]
573        #[unsafe(method_family = new)]
574        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
575    );
576}
577
578extern "C" {
579    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspopupbuttonwillpopupnotification?language=objc)
580    pub static NSPopUpButtonWillPopUpNotification: &'static NSNotificationName;
581}