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