objc2_app_kit/generated/
NSTokenField.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_protocol!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstokenfielddelegate?language=objc)
12    #[cfg(all(feature = "NSControl", feature = "NSTextField"))]
13    pub unsafe trait NSTokenFieldDelegate: NSTextFieldDelegate + MainThreadOnly {
14        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
15        /// Allows the delegate to provide an array of appropriate completions for the contents of the receiver
16        ///
17        /// Parameter `tokenField`: The token field where editing is occurring
18        ///
19        /// Parameter `substring`: The partial string that is being completed
20        ///
21        /// Parameter `tokenIndex`: The index of the token being completed
22        ///
23        /// Parameter `selectedIndex`: Optionally, you can return by reference an index into the returned array that specifies which of the completions should be initially selected. If none are to be selected, return by reference `-1`.
24        ///
25        /// Returns: An array of strings (`NSString`) that are possible completions, or `nil` to provide no completions
26        ///
27        /// If the delegate does not implement this method, no completions are provided
28        #[optional]
29        #[unsafe(method(tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:))]
30        #[unsafe(method_family = none)]
31        unsafe fn tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem(
32            &self,
33            token_field: &NSTokenField,
34            substring: &NSString,
35            token_index: NSInteger,
36            selected_index: *mut NSInteger,
37        ) -> Option<Retained<NSArray>>;
38
39        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
40        #[optional]
41        #[unsafe(method(tokenField:shouldAddObjects:atIndex:))]
42        #[unsafe(method_family = none)]
43        unsafe fn tokenField_shouldAddObjects_atIndex(
44            &self,
45            token_field: &NSTokenField,
46            tokens: &NSArray,
47            index: NSUInteger,
48        ) -> Retained<NSArray>;
49
50        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
51        #[optional]
52        #[unsafe(method(tokenField:displayStringForRepresentedObject:))]
53        #[unsafe(method_family = none)]
54        unsafe fn tokenField_displayStringForRepresentedObject(
55            &self,
56            token_field: &NSTokenField,
57            represented_object: &AnyObject,
58        ) -> Option<Retained<NSString>>;
59
60        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
61        #[optional]
62        #[unsafe(method(tokenField:editingStringForRepresentedObject:))]
63        #[unsafe(method_family = none)]
64        unsafe fn tokenField_editingStringForRepresentedObject(
65            &self,
66            token_field: &NSTokenField,
67            represented_object: &AnyObject,
68        ) -> Option<Retained<NSString>>;
69
70        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
71        #[optional]
72        #[unsafe(method(tokenField:representedObjectForEditingString:))]
73        #[unsafe(method_family = none)]
74        unsafe fn tokenField_representedObjectForEditingString(
75            &self,
76            token_field: &NSTokenField,
77            editing_string: &NSString,
78        ) -> Option<Retained<AnyObject>>;
79
80        #[cfg(all(feature = "NSPasteboard", feature = "NSResponder", feature = "NSView"))]
81        #[optional]
82        #[unsafe(method(tokenField:writeRepresentedObjects:toPasteboard:))]
83        #[unsafe(method_family = none)]
84        unsafe fn tokenField_writeRepresentedObjects_toPasteboard(
85            &self,
86            token_field: &NSTokenField,
87            objects: &NSArray,
88            pboard: &NSPasteboard,
89        ) -> bool;
90
91        #[cfg(all(feature = "NSPasteboard", feature = "NSResponder", feature = "NSView"))]
92        #[optional]
93        #[unsafe(method(tokenField:readFromPasteboard:))]
94        #[unsafe(method_family = none)]
95        unsafe fn tokenField_readFromPasteboard(
96            &self,
97            token_field: &NSTokenField,
98            pboard: &NSPasteboard,
99        ) -> Option<Retained<NSArray>>;
100
101        #[cfg(all(feature = "NSMenu", feature = "NSResponder", feature = "NSView"))]
102        #[optional]
103        #[unsafe(method(tokenField:menuForRepresentedObject:))]
104        #[unsafe(method_family = none)]
105        unsafe fn tokenField_menuForRepresentedObject(
106            &self,
107            token_field: &NSTokenField,
108            represented_object: &AnyObject,
109        ) -> Option<Retained<NSMenu>>;
110
111        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
112        #[optional]
113        #[unsafe(method(tokenField:hasMenuForRepresentedObject:))]
114        #[unsafe(method_family = none)]
115        unsafe fn tokenField_hasMenuForRepresentedObject(
116            &self,
117            token_field: &NSTokenField,
118            represented_object: &AnyObject,
119        ) -> bool;
120
121        #[cfg(all(
122            feature = "NSResponder",
123            feature = "NSTokenFieldCell",
124            feature = "NSView"
125        ))]
126        #[optional]
127        #[unsafe(method(tokenField:styleForRepresentedObject:))]
128        #[unsafe(method_family = none)]
129        unsafe fn tokenField_styleForRepresentedObject(
130            &self,
131            token_field: &NSTokenField,
132            represented_object: &AnyObject,
133        ) -> NSTokenStyle;
134    }
135);
136
137extern_class!(
138    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstokenfield?language=objc)
139    #[unsafe(super(NSTextField, NSControl, NSView, NSResponder, NSObject))]
140    #[derive(Debug, PartialEq, Eq, Hash)]
141    #[cfg(all(
142        feature = "NSControl",
143        feature = "NSResponder",
144        feature = "NSTextField",
145        feature = "NSView"
146    ))]
147    pub struct NSTokenField;
148);
149
150#[cfg(all(
151    feature = "NSAccessibilityProtocols",
152    feature = "NSControl",
153    feature = "NSResponder",
154    feature = "NSTextField",
155    feature = "NSView"
156))]
157unsafe impl NSAccessibility for NSTokenField {}
158
159#[cfg(all(
160    feature = "NSAccessibilityProtocols",
161    feature = "NSControl",
162    feature = "NSResponder",
163    feature = "NSTextField",
164    feature = "NSView"
165))]
166unsafe impl NSAccessibilityElementProtocol for NSTokenField {}
167
168#[cfg(all(
169    feature = "NSAccessibilityProtocols",
170    feature = "NSControl",
171    feature = "NSResponder",
172    feature = "NSTextField",
173    feature = "NSView"
174))]
175unsafe impl NSAccessibilityNavigableStaticText for NSTokenField {}
176
177#[cfg(all(
178    feature = "NSAccessibilityProtocols",
179    feature = "NSControl",
180    feature = "NSResponder",
181    feature = "NSTextField",
182    feature = "NSView"
183))]
184unsafe impl NSAccessibilityStaticText for NSTokenField {}
185
186#[cfg(all(
187    feature = "NSAnimation",
188    feature = "NSControl",
189    feature = "NSResponder",
190    feature = "NSTextField",
191    feature = "NSView"
192))]
193unsafe impl NSAnimatablePropertyContainer for NSTokenField {}
194
195#[cfg(all(
196    feature = "NSAppearance",
197    feature = "NSControl",
198    feature = "NSResponder",
199    feature = "NSTextField",
200    feature = "NSView"
201))]
202unsafe impl NSAppearanceCustomization for NSTokenField {}
203
204#[cfg(all(
205    feature = "NSControl",
206    feature = "NSResponder",
207    feature = "NSTextField",
208    feature = "NSView"
209))]
210unsafe impl NSCoding for NSTokenField {}
211
212#[cfg(all(
213    feature = "NSControl",
214    feature = "NSDragging",
215    feature = "NSResponder",
216    feature = "NSTextField",
217    feature = "NSView"
218))]
219unsafe impl NSDraggingDestination for NSTokenField {}
220
221#[cfg(all(
222    feature = "NSControl",
223    feature = "NSResponder",
224    feature = "NSTextField",
225    feature = "NSView"
226))]
227unsafe impl NSObjectProtocol for NSTokenField {}
228
229#[cfg(all(
230    feature = "NSControl",
231    feature = "NSResponder",
232    feature = "NSTextContent",
233    feature = "NSTextField",
234    feature = "NSView"
235))]
236unsafe impl NSTextContent for NSTokenField {}
237
238#[cfg(all(
239    feature = "NSControl",
240    feature = "NSResponder",
241    feature = "NSTextField",
242    feature = "NSUserInterfaceItemIdentification",
243    feature = "NSView"
244))]
245unsafe impl NSUserInterfaceItemIdentification for NSTokenField {}
246
247#[cfg(all(
248    feature = "NSControl",
249    feature = "NSResponder",
250    feature = "NSTextField",
251    feature = "NSUserInterfaceValidation",
252    feature = "NSView"
253))]
254unsafe impl NSUserInterfaceValidations for NSTokenField {}
255
256#[cfg(all(
257    feature = "NSControl",
258    feature = "NSResponder",
259    feature = "NSTextField",
260    feature = "NSView"
261))]
262impl NSTokenField {
263    extern_methods!(
264        #[unsafe(method(delegate))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn delegate(&self)
267            -> Option<Retained<ProtocolObject<dyn NSTokenFieldDelegate>>>;
268
269        /// This is a [weak property][objc2::topics::weak_property].
270        /// Setter for [`delegate`][Self::delegate].
271        #[unsafe(method(setDelegate:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn setDelegate(
274            &self,
275            delegate: Option<&ProtocolObject<dyn NSTokenFieldDelegate>>,
276        );
277
278        #[cfg(feature = "NSTokenFieldCell")]
279        #[unsafe(method(tokenStyle))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn tokenStyle(&self) -> NSTokenStyle;
282
283        #[cfg(feature = "NSTokenFieldCell")]
284        /// Setter for [`tokenStyle`][Self::tokenStyle].
285        #[unsafe(method(setTokenStyle:))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn setTokenStyle(&self, token_style: NSTokenStyle);
288
289        #[unsafe(method(completionDelay))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn completionDelay(&self) -> NSTimeInterval;
292
293        /// Setter for [`completionDelay`][Self::completionDelay].
294        #[unsafe(method(setCompletionDelay:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn setCompletionDelay(&self, completion_delay: NSTimeInterval);
297
298        #[unsafe(method(defaultCompletionDelay))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn defaultCompletionDelay(mtm: MainThreadMarker) -> NSTimeInterval;
301
302        #[unsafe(method(tokenizingCharacterSet))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn tokenizingCharacterSet(&self) -> Retained<NSCharacterSet>;
305
306        /// Setter for [`tokenizingCharacterSet`][Self::tokenizingCharacterSet].
307        #[unsafe(method(setTokenizingCharacterSet:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn setTokenizingCharacterSet(
310            &self,
311            tokenizing_character_set: Option<&NSCharacterSet>,
312        );
313
314        #[unsafe(method(defaultTokenizingCharacterSet))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn defaultTokenizingCharacterSet(
317            mtm: MainThreadMarker,
318        ) -> Retained<NSCharacterSet>;
319    );
320}
321
322/// Methods declared on superclass `NSControl`.
323#[cfg(all(
324    feature = "NSControl",
325    feature = "NSResponder",
326    feature = "NSTextField",
327    feature = "NSView"
328))]
329impl NSTokenField {
330    extern_methods!(
331        #[unsafe(method(initWithFrame:))]
332        #[unsafe(method_family = init)]
333        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
334
335        #[unsafe(method(initWithCoder:))]
336        #[unsafe(method_family = init)]
337        pub unsafe fn initWithCoder(
338            this: Allocated<Self>,
339            coder: &NSCoder,
340        ) -> Option<Retained<Self>>;
341    );
342}
343
344/// Methods declared on superclass `NSResponder`.
345#[cfg(all(
346    feature = "NSControl",
347    feature = "NSResponder",
348    feature = "NSTextField",
349    feature = "NSView"
350))]
351impl NSTokenField {
352    extern_methods!(
353        #[unsafe(method(init))]
354        #[unsafe(method_family = init)]
355        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
356    );
357}
358
359/// Methods declared on superclass `NSObject`.
360#[cfg(all(
361    feature = "NSControl",
362    feature = "NSResponder",
363    feature = "NSTextField",
364    feature = "NSView"
365))]
366impl NSTokenField {
367    extern_methods!(
368        #[unsafe(method(new))]
369        #[unsafe(method_family = new)]
370        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
371    );
372}