objc2_app_kit/generated/
NSSearchToolbarItem.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
12extern_class!(
13    /// `NSSearchToolbarItem` provides the standard UI behavior for integrating a search field into the toolbar.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssearchtoolbaritem?language=objc)
16    #[unsafe(super(NSToolbarItem, NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    #[cfg(feature = "NSToolbarItem")]
19    pub struct NSSearchToolbarItem;
20);
21
22#[cfg(feature = "NSToolbarItem")]
23unsafe impl NSCopying for NSSearchToolbarItem {}
24
25#[cfg(feature = "NSToolbarItem")]
26unsafe impl CopyingHelper for NSSearchToolbarItem {
27    type Result = Self;
28}
29
30#[cfg(feature = "NSToolbarItem")]
31unsafe impl NSObjectProtocol for NSSearchToolbarItem {}
32
33#[cfg(feature = "NSToolbarItem")]
34impl NSSearchToolbarItem {
35    extern_methods!(
36        #[cfg(all(
37            feature = "NSControl",
38            feature = "NSResponder",
39            feature = "NSSearchField",
40            feature = "NSTextField",
41            feature = "NSView"
42        ))]
43        /// An `NSSearchField` displayed in the toolbar item.
44        /// While inside the toolbar item, the field properties and layout constraints are managed by the item.
45        /// The field should be configured before assigned.
46        /// The width constraint for the field could be updated after assigned.
47        /// When set to nil, will reset to a search field with the default configuration.
48        #[unsafe(method(searchField))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn searchField(&self) -> Retained<NSSearchField>;
51
52        #[cfg(all(
53            feature = "NSControl",
54            feature = "NSResponder",
55            feature = "NSSearchField",
56            feature = "NSTextField",
57            feature = "NSView"
58        ))]
59        /// Setter for [`searchField`][Self::searchField].
60        #[unsafe(method(setSearchField:))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn setSearchField(&self, search_field: &NSSearchField);
63
64        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
65        /// The base view property is owned by the toolbar item and not available for customization.
66        #[unsafe(method(view))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn view(&self) -> Option<Retained<NSView>>;
69
70        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
71        /// Setter for [`view`][Self::view].
72        #[unsafe(method(setView:))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn setView(&self, view: Option<&NSView>);
75
76        /// When YES, the cancel button in the field resigns the first responder status of the search field as clearing the contents.
77        /// The default is YES.
78        #[unsafe(method(resignsFirstResponderWithCancel))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn resignsFirstResponderWithCancel(&self) -> bool;
81
82        /// Setter for [`resignsFirstResponderWithCancel`][Self::resignsFirstResponderWithCancel].
83        #[unsafe(method(setResignsFirstResponderWithCancel:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn setResignsFirstResponderWithCancel(
86            &self,
87            resigns_first_responder_with_cancel: bool,
88        );
89
90        #[cfg(feature = "objc2-core-foundation")]
91        /// The preferred width for the search field.
92        /// This value is used to configure the search field width whenever it gets the keyboard focus.
93        /// If specifying custom width constraints to the search field, they should not conflict with this value.
94        #[unsafe(method(preferredWidthForSearchField))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn preferredWidthForSearchField(&self) -> CGFloat;
97
98        #[cfg(feature = "objc2-core-foundation")]
99        /// Setter for [`preferredWidthForSearchField`][Self::preferredWidthForSearchField].
100        #[unsafe(method(setPreferredWidthForSearchField:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn setPreferredWidthForSearchField(
103            &self,
104            preferred_width_for_search_field: CGFloat,
105        );
106
107        /// Starts a search interaction.
108        /// If necessary, expands to the preferred width and moves the keyboard focus to the search field.
109        #[unsafe(method(beginSearchInteraction))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn beginSearchInteraction(&self);
112
113        /// Ends a search interaction.
114        /// Gives up the first responder by calling `-endEditing:` to the search field.
115        /// Adjusts to the natural available width for the toolbar item if necessary.
116        #[unsafe(method(endSearchInteraction))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn endSearchInteraction(&self);
119    );
120}
121
122/// Methods declared on superclass `NSToolbarItem`.
123#[cfg(feature = "NSToolbarItem")]
124impl NSSearchToolbarItem {
125    extern_methods!(
126        #[cfg(feature = "NSToolbar")]
127        /// Initialize the toolbar item with an identifier which is a development language string used by the toolbar and its delegate for identification purposes.
128        #[unsafe(method(initWithItemIdentifier:))]
129        #[unsafe(method_family = init)]
130        pub unsafe fn initWithItemIdentifier(
131            this: Allocated<Self>,
132            item_identifier: &NSToolbarItemIdentifier,
133        ) -> Retained<Self>;
134    );
135}
136
137/// Methods declared on superclass `NSObject`.
138#[cfg(feature = "NSToolbarItem")]
139impl NSSearchToolbarItem {
140    extern_methods!(
141        #[unsafe(method(init))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
144
145        #[unsafe(method(new))]
146        #[unsafe(method_family = new)]
147        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
148    );
149}