objc2_app_kit/generated/
NSButton.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/nsbutton?language=objc)
12    #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
15    pub struct NSButton;
16);
17
18#[cfg(all(
19    feature = "NSAccessibilityProtocols",
20    feature = "NSControl",
21    feature = "NSResponder",
22    feature = "NSView"
23))]
24extern_conformance!(
25    unsafe impl NSAccessibility for NSButton {}
26);
27
28#[cfg(all(
29    feature = "NSAccessibilityProtocols",
30    feature = "NSControl",
31    feature = "NSResponder",
32    feature = "NSView"
33))]
34extern_conformance!(
35    unsafe impl NSAccessibilityButton for NSButton {}
36);
37
38#[cfg(all(
39    feature = "NSAccessibilityProtocols",
40    feature = "NSControl",
41    feature = "NSResponder",
42    feature = "NSView"
43))]
44extern_conformance!(
45    unsafe impl NSAccessibilityElementProtocol for NSButton {}
46);
47
48#[cfg(all(
49    feature = "NSAnimation",
50    feature = "NSControl",
51    feature = "NSResponder",
52    feature = "NSView"
53))]
54extern_conformance!(
55    unsafe impl NSAnimatablePropertyContainer for NSButton {}
56);
57
58#[cfg(all(
59    feature = "NSAppearance",
60    feature = "NSControl",
61    feature = "NSResponder",
62    feature = "NSView"
63))]
64extern_conformance!(
65    unsafe impl NSAppearanceCustomization for NSButton {}
66);
67
68#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
69extern_conformance!(
70    unsafe impl NSCoding for NSButton {}
71);
72
73#[cfg(all(
74    feature = "NSControl",
75    feature = "NSDragging",
76    feature = "NSResponder",
77    feature = "NSView"
78))]
79extern_conformance!(
80    unsafe impl NSDraggingDestination for NSButton {}
81);
82
83#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
84extern_conformance!(
85    unsafe impl NSObjectProtocol for NSButton {}
86);
87
88#[cfg(all(
89    feature = "NSControl",
90    feature = "NSResponder",
91    feature = "NSUserInterfaceCompression",
92    feature = "NSView"
93))]
94extern_conformance!(
95    unsafe impl NSUserInterfaceCompression for NSButton {}
96);
97
98#[cfg(all(
99    feature = "NSControl",
100    feature = "NSResponder",
101    feature = "NSUserInterfaceItemIdentification",
102    feature = "NSView"
103))]
104extern_conformance!(
105    unsafe impl NSUserInterfaceItemIdentification for NSButton {}
106);
107
108#[cfg(all(
109    feature = "NSControl",
110    feature = "NSResponder",
111    feature = "NSUserInterfaceValidation",
112    feature = "NSView"
113))]
114extern_conformance!(
115    unsafe impl NSUserInterfaceValidations for NSButton {}
116);
117
118#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
119impl NSButton {
120    extern_methods!(
121        #[cfg(feature = "NSImage")]
122        /// Creates a standard push button with a title and image.
123        ///
124        /// Parameter `title`: The localized title string that is displayed on the button.
125        ///
126        /// 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.
127        ///
128        /// Parameter `target`: The target object that receives action messages from the control.
129        ///
130        /// Parameter `action`: The action message sent by the control.
131        ///
132        /// Returns: An initialized button object.
133        ///
134        /// # Safety
135        ///
136        /// - `target` should be of the correct type.
137        /// - `action` must be a valid selector.
138        #[unsafe(method(buttonWithTitle:image:target:action:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn buttonWithTitle_image_target_action(
141            title: &NSString,
142            image: &NSImage,
143            target: Option<&AnyObject>,
144            action: Option<Sel>,
145            mtm: MainThreadMarker,
146        ) -> Retained<Self>;
147
148        /// Creates a standard push button with the provided title.
149        ///
150        /// Parameter `title`: The localized title string that is displayed on the button.
151        ///
152        /// Parameter `target`: The target object that receives action messages from the control.
153        ///
154        /// Parameter `action`: The action message sent by the control.
155        ///
156        /// Returns: An initialized button object.
157        ///
158        /// # Safety
159        ///
160        /// - `target` should be of the correct type.
161        /// - `action` must be a valid selector.
162        #[unsafe(method(buttonWithTitle:target:action:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn buttonWithTitle_target_action(
165            title: &NSString,
166            target: Option<&AnyObject>,
167            action: Option<Sel>,
168            mtm: MainThreadMarker,
169        ) -> Retained<Self>;
170
171        #[cfg(feature = "NSImage")]
172        /// Creates a standard push button with the provided image. Set the image's accessibilityDescription property to ensure accessibility for this control.
173        ///
174        /// Parameter `image`: The image to display in the body of the button.
175        ///
176        /// Parameter `target`: The target object that receives action messages from the control.
177        ///
178        /// Parameter `action`: The action message sent by the control.
179        ///
180        /// Returns: An initialized button object.
181        ///
182        /// # Safety
183        ///
184        /// - `target` should be of the correct type.
185        /// - `action` must be a valid selector.
186        #[unsafe(method(buttonWithImage:target:action:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn buttonWithImage_target_action(
189            image: &NSImage,
190            target: Option<&AnyObject>,
191            action: Option<Sel>,
192            mtm: MainThreadMarker,
193        ) -> Retained<Self>;
194
195        /// Creates a standard checkbox with the provided title.
196        ///
197        /// Parameter `title`: The localized title string that is displayed alongside the checkbox.
198        ///
199        /// Parameter `target`: The target object that receives action messages from the control.
200        ///
201        /// Parameter `action`: The action message sent by the control.
202        ///
203        /// Returns: An initialized button object.
204        ///
205        /// # Safety
206        ///
207        /// - `target` should be of the correct type.
208        /// - `action` must be a valid selector.
209        #[unsafe(method(checkboxWithTitle:target:action:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn checkboxWithTitle_target_action(
212            title: &NSString,
213            target: Option<&AnyObject>,
214            action: Option<Sel>,
215            mtm: MainThreadMarker,
216        ) -> Retained<Self>;
217
218        /// Creates a standard radio button with the provided title.
219        ///
220        /// Parameter `title`: The localized title string that is displayed alongside the radio button.
221        ///
222        /// Parameter `target`: The target object that receives action messages from the control.
223        ///
224        /// Parameter `action`: The action message sent by the control.
225        ///
226        /// Returns: An initialized button object.
227        ///
228        /// # Safety
229        ///
230        /// - `target` should be of the correct type.
231        /// - `action` must be a valid selector.
232        #[unsafe(method(radioButtonWithTitle:target:action:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn radioButtonWithTitle_target_action(
235            title: &NSString,
236            target: Option<&AnyObject>,
237            action: Option<Sel>,
238            mtm: MainThreadMarker,
239        ) -> Retained<Self>;
240
241        #[cfg(feature = "NSButtonCell")]
242        /// Sets the button’s type, which affects its user interface and behavior when clicked. See the NSButtonType enumeration for possible options and their behaviors.
243        #[unsafe(method(setButtonType:))]
244        #[unsafe(method_family = none)]
245        pub fn setButtonType(&self, r#type: NSButtonType);
246
247        /// The title displayed on the button when it’s in an off state, or an empty string if the button does not display a title. By default, a button's title is "Button".
248        #[unsafe(method(title))]
249        #[unsafe(method_family = none)]
250        pub fn title(&self) -> Retained<NSString>;
251
252        /// Setter for [`title`][Self::title].
253        ///
254        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
255        #[unsafe(method(setTitle:))]
256        #[unsafe(method_family = none)]
257        pub fn setTitle(&self, title: &NSString);
258
259        /// The button's title, expressed as an attributed string.
260        #[unsafe(method(attributedTitle))]
261        #[unsafe(method_family = none)]
262        pub fn attributedTitle(&self) -> Retained<NSAttributedString>;
263
264        /// Setter for [`attributedTitle`][Self::attributedTitle].
265        ///
266        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
267        #[unsafe(method(setAttributedTitle:))]
268        #[unsafe(method_family = none)]
269        pub fn setAttributedTitle(&self, attributed_title: &NSAttributedString);
270
271        /// The title that the button displays when the button is in an on state, or an empty string if there is no such title. Note that some button types do not display an alternate title.
272        #[unsafe(method(alternateTitle))]
273        #[unsafe(method_family = none)]
274        pub fn alternateTitle(&self) -> Retained<NSString>;
275
276        /// Setter for [`alternateTitle`][Self::alternateTitle].
277        ///
278        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
279        #[unsafe(method(setAlternateTitle:))]
280        #[unsafe(method_family = none)]
281        pub fn setAlternateTitle(&self, alternate_title: &NSString);
282
283        /// The alternate title, expressed as an attributed string.
284        #[unsafe(method(attributedAlternateTitle))]
285        #[unsafe(method_family = none)]
286        pub fn attributedAlternateTitle(&self) -> Retained<NSAttributedString>;
287
288        /// Setter for [`attributedAlternateTitle`][Self::attributedAlternateTitle].
289        ///
290        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
291        #[unsafe(method(setAttributedAlternateTitle:))]
292        #[unsafe(method_family = none)]
293        pub fn setAttributedAlternateTitle(&self, attributed_alternate_title: &NSAttributedString);
294
295        /// Indicates whether the button's action has a destructive effect on user data.  AppKit may guard a destructive-actioned button against accidental presses, and may give the button a special appearance in certain contexts to caution against unintentional use.  Defaults to NO.
296        #[unsafe(method(hasDestructiveAction))]
297        #[unsafe(method_family = none)]
298        pub fn hasDestructiveAction(&self) -> bool;
299
300        /// Setter for [`hasDestructiveAction`][Self::hasDestructiveAction].
301        #[unsafe(method(setHasDestructiveAction:))]
302        #[unsafe(method_family = none)]
303        pub fn setHasDestructiveAction(&self, has_destructive_action: bool);
304
305        #[cfg(feature = "NSSound")]
306        /// The sound that plays when the user clicks the button, or nil if the button should not play a sound. The default value is nil.
307        #[unsafe(method(sound))]
308        #[unsafe(method_family = none)]
309        pub fn sound(&self) -> Option<Retained<NSSound>>;
310
311        #[cfg(feature = "NSSound")]
312        /// Setter for [`sound`][Self::sound].
313        #[unsafe(method(setSound:))]
314        #[unsafe(method_family = none)]
315        pub fn setSound(&self, sound: Option<&NSSound>);
316
317        /// Sends action on deep-press or extended hover while dragging. Defaults to NO.
318        #[unsafe(method(isSpringLoaded))]
319        #[unsafe(method_family = none)]
320        pub fn isSpringLoaded(&self) -> bool;
321
322        /// Setter for [`isSpringLoaded`][Self::isSpringLoaded].
323        #[unsafe(method(setSpringLoaded:))]
324        #[unsafe(method_family = none)]
325        pub fn setSpringLoaded(&self, spring_loaded: bool);
326
327        /// Configures the maximum allowed level for an NSMultiLevelAcceleratorButton, allowed values range from [1,5]. Defaults to 2.
328        #[unsafe(method(maxAcceleratorLevel))]
329        #[unsafe(method_family = none)]
330        pub fn maxAcceleratorLevel(&self) -> NSInteger;
331
332        /// Setter for [`maxAcceleratorLevel`][Self::maxAcceleratorLevel].
333        #[unsafe(method(setMaxAcceleratorLevel:))]
334        #[unsafe(method_family = none)]
335        pub fn setMaxAcceleratorLevel(&self, max_accelerator_level: NSInteger);
336
337        /// Sets the initial delay and repeat interval, in seconds, for repeated action messages sent when `continuous` is YES.
338        #[unsafe(method(setPeriodicDelay:interval:))]
339        #[unsafe(method_family = none)]
340        pub fn setPeriodicDelay_interval(&self, delay: c_float, interval: c_float);
341
342        /// Gets the initial delay and repeat interval, in seconds, for repeated action messages sent when `continuous` is YES. Both parameters to this method must not be NULL.
343        ///
344        /// # Safety
345        ///
346        /// - `delay` must be a valid pointer.
347        /// - `interval` must be a valid pointer.
348        #[unsafe(method(getPeriodicDelay:interval:))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn getPeriodicDelay_interval(
351            &self,
352            delay: NonNull<c_float>,
353            interval: NonNull<c_float>,
354        );
355
356        #[cfg(feature = "NSButtonCell")]
357        /// The bezel style of the button, which provides a set of bezel artwork, layout metrics, and content styling from a set of system-provided styles. See the NSBezelStyle enumeration for a list of available styles. The bezel style is not used if the `bordered` property is set to `NO`.
358        #[unsafe(method(bezelStyle))]
359        #[unsafe(method_family = none)]
360        pub fn bezelStyle(&self) -> NSBezelStyle;
361
362        #[cfg(feature = "NSButtonCell")]
363        /// Setter for [`bezelStyle`][Self::bezelStyle].
364        #[unsafe(method(setBezelStyle:))]
365        #[unsafe(method_family = none)]
366        pub fn setBezelStyle(&self, bezel_style: NSBezelStyle);
367
368        /// A Boolean value that determines whether the button draws a border.
369        #[unsafe(method(isBordered))]
370        #[unsafe(method_family = none)]
371        pub fn isBordered(&self) -> bool;
372
373        /// Setter for [`isBordered`][Self::isBordered].
374        #[unsafe(method(setBordered:))]
375        #[unsafe(method_family = none)]
376        pub fn setBordered(&self, bordered: bool);
377
378        /// A Boolean value that indicates whether the button is transparent. A transparent button never draws itself, but it receives mouse events, sends its action, and tracks the mouse properly.
379        #[unsafe(method(isTransparent))]
380        #[unsafe(method_family = none)]
381        pub fn isTransparent(&self) -> bool;
382
383        /// Setter for [`isTransparent`][Self::isTransparent].
384        #[unsafe(method(setTransparent:))]
385        #[unsafe(method_family = none)]
386        pub fn setTransparent(&self, transparent: bool);
387
388        #[unsafe(method(showsBorderOnlyWhileMouseInside))]
389        #[unsafe(method_family = none)]
390        pub fn showsBorderOnlyWhileMouseInside(&self) -> bool;
391
392        /// Setter for [`showsBorderOnlyWhileMouseInside`][Self::showsBorderOnlyWhileMouseInside].
393        #[unsafe(method(setShowsBorderOnlyWhileMouseInside:))]
394        #[unsafe(method_family = none)]
395        pub fn setShowsBorderOnlyWhileMouseInside(
396            &self,
397            shows_border_only_while_mouse_inside: bool,
398        );
399
400        #[cfg(feature = "NSColor")]
401        /// Applies a custom color to the button's bezel, in appearances that support it. A nil value indicates an unmodified button appearance. The default value is nil.
402        #[unsafe(method(bezelColor))]
403        #[unsafe(method_family = none)]
404        pub fn bezelColor(&self) -> Option<Retained<NSColor>>;
405
406        #[cfg(feature = "NSColor")]
407        /// Setter for [`bezelColor`][Self::bezelColor].
408        ///
409        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
410        #[unsafe(method(setBezelColor:))]
411        #[unsafe(method_family = none)]
412        pub fn setBezelColor(&self, bezel_color: Option<&NSColor>);
413
414        #[cfg(feature = "NSColor")]
415        /// Applies a tint color to template image and text content, in combination with other theme-appropriate effects. Only applicable to borderless buttons. A nil value indicates the standard set of effects without color modification. The default value is nil. Non-template images and attributed string values are not affected by the contentTintColor.
416        #[unsafe(method(contentTintColor))]
417        #[unsafe(method_family = none)]
418        pub fn contentTintColor(&self) -> Option<Retained<NSColor>>;
419
420        #[cfg(feature = "NSColor")]
421        /// Setter for [`contentTintColor`][Self::contentTintColor].
422        ///
423        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
424        #[unsafe(method(setContentTintColor:))]
425        #[unsafe(method_family = none)]
426        pub fn setContentTintColor(&self, content_tint_color: Option<&NSColor>);
427
428        #[cfg(feature = "NSTintProminence")]
429        /// The tint prominence of the button. Use tint prominence to gently suggest a hierarchy when multiple buttons perform similar actions. A button with primary tint prominence suggests the most preferred option, while secondary prominence indicates a reasonable alternative. See ``NSTintProminence`` for a list of possible values.
430        #[unsafe(method(tintProminence))]
431        #[unsafe(method_family = none)]
432        pub fn tintProminence(&self) -> NSTintProminence;
433
434        #[cfg(feature = "NSTintProminence")]
435        /// Setter for [`tintProminence`][Self::tintProminence].
436        #[unsafe(method(setTintProminence:))]
437        #[unsafe(method_family = none)]
438        pub fn setTintProminence(&self, tint_prominence: NSTintProminence);
439
440        #[cfg(feature = "NSImage")]
441        /// The image that appears on the button when it’s in an off state, or nil if there is no such image.
442        #[unsafe(method(image))]
443        #[unsafe(method_family = none)]
444        pub fn image(&self) -> Option<Retained<NSImage>>;
445
446        #[cfg(feature = "NSImage")]
447        /// Setter for [`image`][Self::image].
448        #[unsafe(method(setImage:))]
449        #[unsafe(method_family = none)]
450        pub fn setImage(&self, image: Option<&NSImage>);
451
452        #[cfg(feature = "NSImage")]
453        /// An alternate image that appears on the button when the button is in an on state, or nil if there is no such image. Note that some button types do not display an alternate image.
454        #[unsafe(method(alternateImage))]
455        #[unsafe(method_family = none)]
456        pub fn alternateImage(&self) -> Option<Retained<NSImage>>;
457
458        #[cfg(feature = "NSImage")]
459        /// Setter for [`alternateImage`][Self::alternateImage].
460        #[unsafe(method(setAlternateImage:))]
461        #[unsafe(method_family = none)]
462        pub fn setAlternateImage(&self, alternate_image: Option<&NSImage>);
463
464        #[cfg(feature = "NSCell")]
465        /// The position of the button's image relative to its title. See the NSCellImagePosition enumeration for possible values.
466        #[unsafe(method(imagePosition))]
467        #[unsafe(method_family = none)]
468        pub fn imagePosition(&self) -> NSCellImagePosition;
469
470        #[cfg(feature = "NSCell")]
471        /// Setter for [`imagePosition`][Self::imagePosition].
472        #[unsafe(method(setImagePosition:))]
473        #[unsafe(method_family = none)]
474        pub fn setImagePosition(&self, image_position: NSCellImagePosition);
475
476        #[cfg(feature = "NSCell")]
477        /// The scaling mode applied to make the button's image fit within its bounds.
478        #[unsafe(method(imageScaling))]
479        #[unsafe(method_family = none)]
480        pub fn imageScaling(&self) -> NSImageScaling;
481
482        #[cfg(feature = "NSCell")]
483        /// Setter for [`imageScaling`][Self::imageScaling].
484        #[unsafe(method(setImageScaling:))]
485        #[unsafe(method_family = none)]
486        pub fn setImageScaling(&self, image_scaling: NSImageScaling);
487
488        /// A Boolean value that determines how the button's image and title are positioned together within the button bezel. If false, the image is positioned according to the imagePosition property at the edge of the button bezel, and the title is positioned within the remaining space. If true, the button’s image is positioned directly adjacent to the title based on the imagePosition property, and the image and title are positioned within the button bezel as a single unit.
489        #[unsafe(method(imageHugsTitle))]
490        #[unsafe(method_family = none)]
491        pub fn imageHugsTitle(&self) -> bool;
492
493        /// Setter for [`imageHugsTitle`][Self::imageHugsTitle].
494        #[unsafe(method(setImageHugsTitle:))]
495        #[unsafe(method_family = none)]
496        pub fn setImageHugsTitle(&self, image_hugs_title: bool);
497
498        #[cfg(feature = "NSImage")]
499        /// Specifies a combination of point size, weight, and scale to use when sizing and displaying symbol images. If a symbol configuration isn't provided, the symbol is matched to the button's `font` property. The default value is nil.
500        #[unsafe(method(symbolConfiguration))]
501        #[unsafe(method_family = none)]
502        pub fn symbolConfiguration(&self) -> Option<Retained<NSImageSymbolConfiguration>>;
503
504        #[cfg(feature = "NSImage")]
505        /// Setter for [`symbolConfiguration`][Self::symbolConfiguration].
506        ///
507        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
508        #[unsafe(method(setSymbolConfiguration:))]
509        #[unsafe(method_family = none)]
510        pub fn setSymbolConfiguration(
511            &self,
512            symbol_configuration: Option<&NSImageSymbolConfiguration>,
513        );
514
515        #[cfg(feature = "NSCell")]
516        /// The button's state. Buttons support the off and on states, and an additional mixed state depending on the value of the `allowsMixedState` property.
517        #[unsafe(method(state))]
518        #[unsafe(method_family = none)]
519        pub fn state(&self) -> NSControlStateValue;
520
521        #[cfg(feature = "NSCell")]
522        /// Setter for [`state`][Self::state].
523        #[unsafe(method(setState:))]
524        #[unsafe(method_family = none)]
525        pub fn setState(&self, state: NSControlStateValue);
526
527        /// A Boolean value that indicates whether the button allows a mixed state. If NO, the button has two states (on and off), and if YES, the button has three states (on, off, and mixed). The mixed state is commonly used with checkboxes and radio buttons to indicate a value which is partially on.
528        #[unsafe(method(allowsMixedState))]
529        #[unsafe(method_family = none)]
530        pub fn allowsMixedState(&self) -> bool;
531
532        /// Setter for [`allowsMixedState`][Self::allowsMixedState].
533        #[unsafe(method(setAllowsMixedState:))]
534        #[unsafe(method_family = none)]
535        pub fn setAllowsMixedState(&self, allows_mixed_state: bool);
536
537        /// Sets the button to its next eligible state. If the button allows mixed state, this cycles through the states in the order: on, off, mixed, on, etc. If the button does not allow mixed state, it toggles between off and on.
538        #[unsafe(method(setNextState))]
539        #[unsafe(method_family = none)]
540        pub fn setNextState(&self);
541
542        /// Highlights, or un-highlights, the button. Highlighting makes the button appear "pressed", which may include showing an illuminated bezel, or showing the alternate image or title, depending on the type of button.
543        #[unsafe(method(highlight:))]
544        #[unsafe(method_family = none)]
545        pub fn highlight(&self, flag: bool);
546
547        /// This property contains the button's key equivalent, or the empty string if no equivalent has been defined. Buttons don’t have a default key equivalent. Setting the key equivalent to the Return character causes it to act as the default button for its window.
548        #[unsafe(method(keyEquivalent))]
549        #[unsafe(method_family = none)]
550        pub fn keyEquivalent(&self) -> Retained<NSString>;
551
552        /// Setter for [`keyEquivalent`][Self::keyEquivalent].
553        ///
554        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
555        #[unsafe(method(setKeyEquivalent:))]
556        #[unsafe(method_family = none)]
557        pub fn setKeyEquivalent(&self, key_equivalent: &NSString);
558
559        #[cfg(feature = "NSEvent")]
560        /// A bitmask specifying the modifier keys that are applied to the button's key equivalent. Mask bits are defined by the NSEventModifierFlags option set. The only mask bits relevant in button key-equivalent modifier masks are NSEventModifierFlagControl, NSEventModifierFlagOption, and NSEventModifierFlagCommand.
561        #[unsafe(method(keyEquivalentModifierMask))]
562        #[unsafe(method_family = none)]
563        pub fn keyEquivalentModifierMask(&self) -> NSEventModifierFlags;
564
565        #[cfg(feature = "NSEvent")]
566        /// Setter for [`keyEquivalentModifierMask`][Self::keyEquivalentModifierMask].
567        #[unsafe(method(setKeyEquivalentModifierMask:))]
568        #[unsafe(method_family = none)]
569        pub fn setKeyEquivalentModifierMask(
570            &self,
571            key_equivalent_modifier_mask: NSEventModifierFlags,
572        );
573
574        #[cfg(feature = "NSEvent")]
575        /// If the event parameter matches the button's key equivalent, the button briefly highlights and performs its action, and then returns YES. Otherwise, returns NO.
576        #[unsafe(method(performKeyEquivalent:))]
577        #[unsafe(method_family = none)]
578        pub fn performKeyEquivalent(&self, key: &NSEvent) -> bool;
579
580        #[cfg(feature = "NSUserInterfaceCompression")]
581        #[unsafe(method(compressWithPrioritizedCompressionOptions:))]
582        #[unsafe(method_family = none)]
583        pub fn compressWithPrioritizedCompressionOptions(
584            &self,
585            prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
586        );
587
588        #[cfg(feature = "NSUserInterfaceCompression")]
589        #[unsafe(method(minimumSizeWithPrioritizedCompressionOptions:))]
590        #[unsafe(method_family = none)]
591        pub fn minimumSizeWithPrioritizedCompressionOptions(
592            &self,
593            prioritized_options: &NSArray<NSUserInterfaceCompressionOptions>,
594        ) -> NSSize;
595
596        #[cfg(feature = "NSUserInterfaceCompression")]
597        #[unsafe(method(activeCompressionOptions))]
598        #[unsafe(method_family = none)]
599        pub fn activeCompressionOptions(&self) -> Retained<NSUserInterfaceCompressionOptions>;
600
601        #[unsafe(method(borderShape))]
602        #[unsafe(method_family = none)]
603        pub fn borderShape(&self) -> NSControlBorderShape;
604
605        /// Setter for [`borderShape`][Self::borderShape].
606        #[unsafe(method(setBorderShape:))]
607        #[unsafe(method_family = none)]
608        pub fn setBorderShape(&self, border_shape: NSControlBorderShape);
609    );
610}
611
612/// Methods declared on superclass `NSControl`.
613#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
614impl NSButton {
615    extern_methods!(
616        #[unsafe(method(initWithFrame:))]
617        #[unsafe(method_family = init)]
618        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
619
620        /// # Safety
621        ///
622        /// `coder` possibly has further requirements.
623        #[unsafe(method(initWithCoder:))]
624        #[unsafe(method_family = init)]
625        pub unsafe fn initWithCoder(
626            this: Allocated<Self>,
627            coder: &NSCoder,
628        ) -> Option<Retained<Self>>;
629    );
630}
631
632/// Methods declared on superclass `NSResponder`.
633#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
634impl NSButton {
635    extern_methods!(
636        #[unsafe(method(init))]
637        #[unsafe(method_family = init)]
638        pub fn init(this: Allocated<Self>) -> Retained<Self>;
639    );
640}
641
642/// Methods declared on superclass `NSObject`.
643#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
644impl NSButton {
645    extern_methods!(
646        #[unsafe(method(new))]
647        #[unsafe(method_family = new)]
648        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
649    );
650}
651
652/// NSButtonDeprecated.
653#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
654impl NSButton {
655    extern_methods!(
656        /// # Safety
657        ///
658        /// `string_with_ampersand` might not allow `None`.
659        #[deprecated = "Mnemonics are not used on macOS. Set the title property directly instead."]
660        #[unsafe(method(setTitleWithMnemonic:))]
661        #[unsafe(method_family = none)]
662        pub unsafe fn setTitleWithMnemonic(&self, string_with_ampersand: Option<&NSString>);
663    );
664}