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 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 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 fn resignsFirstResponderWithCancel(&self) -> bool;
85
86        /// Setter for [`resignsFirstResponderWithCancel`][Self::resignsFirstResponderWithCancel].
87        #[unsafe(method(setResignsFirstResponderWithCancel:))]
88        #[unsafe(method_family = none)]
89        pub fn setResignsFirstResponderWithCancel(&self, resigns_first_responder_with_cancel: bool);
90
91        #[cfg(feature = "objc2-core-foundation")]
92        /// The preferred width for the search field.
93        /// This value is used to configure the search field width whenever it gets the keyboard focus.
94        /// If specifying custom width constraints to the search field, they should not conflict with this value.
95        #[unsafe(method(preferredWidthForSearchField))]
96        #[unsafe(method_family = none)]
97        pub fn preferredWidthForSearchField(&self) -> CGFloat;
98
99        #[cfg(feature = "objc2-core-foundation")]
100        /// Setter for [`preferredWidthForSearchField`][Self::preferredWidthForSearchField].
101        #[unsafe(method(setPreferredWidthForSearchField:))]
102        #[unsafe(method_family = none)]
103        pub fn setPreferredWidthForSearchField(&self, preferred_width_for_search_field: CGFloat);
104
105        /// Starts a search interaction.
106        /// If necessary, expands to the preferred width and moves the keyboard focus to the search field.
107        #[unsafe(method(beginSearchInteraction))]
108        #[unsafe(method_family = none)]
109        pub fn beginSearchInteraction(&self);
110
111        /// Ends a search interaction.
112        /// Gives up the first responder by calling `-endEditing:` to the search field.
113        /// Adjusts to the natural available width for the toolbar item if necessary.
114        #[unsafe(method(endSearchInteraction))]
115        #[unsafe(method_family = none)]
116        pub fn endSearchInteraction(&self);
117    );
118}
119
120/// Methods declared on superclass `NSToolbarItem`.
121#[cfg(feature = "NSToolbarItem")]
122impl NSSearchToolbarItem {
123    extern_methods!(
124        #[cfg(feature = "NSToolbar")]
125        /// Initialize the toolbar item with an identifier which is a development language string used by the toolbar and its delegate for identification purposes.
126        #[unsafe(method(initWithItemIdentifier:))]
127        #[unsafe(method_family = init)]
128        pub fn initWithItemIdentifier(
129            this: Allocated<Self>,
130            item_identifier: &NSToolbarItemIdentifier,
131        ) -> Retained<Self>;
132    );
133}
134
135/// Methods declared on superclass `NSObject`.
136#[cfg(feature = "NSToolbarItem")]
137impl NSSearchToolbarItem {
138    extern_methods!(
139        #[unsafe(method(init))]
140        #[unsafe(method_family = init)]
141        pub fn init(this: Allocated<Self>) -> Retained<Self>;
142
143        #[unsafe(method(new))]
144        #[unsafe(method_family = new)]
145        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
146    );
147}