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        ///
29        /// # Safety
30        ///
31        /// `selected_index` must be a valid pointer or null.
32        #[optional]
33        #[unsafe(method(tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:))]
34        #[unsafe(method_family = none)]
35        unsafe fn tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem(
36            &self,
37            token_field: &NSTokenField,
38            substring: &NSString,
39            token_index: NSInteger,
40            selected_index: *mut NSInteger,
41        ) -> Option<Retained<NSArray>>;
42
43        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
44        /// # Safety
45        ///
46        /// `tokens` generic should be of the correct type.
47        #[optional]
48        #[unsafe(method(tokenField:shouldAddObjects:atIndex:))]
49        #[unsafe(method_family = none)]
50        unsafe fn tokenField_shouldAddObjects_atIndex(
51            &self,
52            token_field: &NSTokenField,
53            tokens: &NSArray,
54            index: NSUInteger,
55        ) -> Retained<NSArray>;
56
57        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
58        /// # Safety
59        ///
60        /// `represented_object` should be of the correct type.
61        #[optional]
62        #[unsafe(method(tokenField:displayStringForRepresentedObject:))]
63        #[unsafe(method_family = none)]
64        unsafe fn tokenField_displayStringForRepresentedObject(
65            &self,
66            token_field: &NSTokenField,
67            represented_object: &AnyObject,
68        ) -> Option<Retained<NSString>>;
69
70        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
71        /// # Safety
72        ///
73        /// `represented_object` should be of the correct type.
74        #[optional]
75        #[unsafe(method(tokenField:editingStringForRepresentedObject:))]
76        #[unsafe(method_family = none)]
77        unsafe fn tokenField_editingStringForRepresentedObject(
78            &self,
79            token_field: &NSTokenField,
80            represented_object: &AnyObject,
81        ) -> Option<Retained<NSString>>;
82
83        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
84        #[optional]
85        #[unsafe(method(tokenField:representedObjectForEditingString:))]
86        #[unsafe(method_family = none)]
87        fn tokenField_representedObjectForEditingString(
88            &self,
89            token_field: &NSTokenField,
90            editing_string: &NSString,
91        ) -> Option<Retained<AnyObject>>;
92
93        #[cfg(all(feature = "NSPasteboard", feature = "NSResponder", feature = "NSView"))]
94        /// # Safety
95        ///
96        /// `objects` generic should be of the correct type.
97        #[optional]
98        #[unsafe(method(tokenField:writeRepresentedObjects:toPasteboard:))]
99        #[unsafe(method_family = none)]
100        unsafe fn tokenField_writeRepresentedObjects_toPasteboard(
101            &self,
102            token_field: &NSTokenField,
103            objects: &NSArray,
104            pboard: &NSPasteboard,
105        ) -> bool;
106
107        #[cfg(all(feature = "NSPasteboard", feature = "NSResponder", feature = "NSView"))]
108        #[optional]
109        #[unsafe(method(tokenField:readFromPasteboard:))]
110        #[unsafe(method_family = none)]
111        fn tokenField_readFromPasteboard(
112            &self,
113            token_field: &NSTokenField,
114            pboard: &NSPasteboard,
115        ) -> Option<Retained<NSArray>>;
116
117        #[cfg(all(feature = "NSMenu", feature = "NSResponder", feature = "NSView"))]
118        /// # Safety
119        ///
120        /// `represented_object` should be of the correct type.
121        #[optional]
122        #[unsafe(method(tokenField:menuForRepresentedObject:))]
123        #[unsafe(method_family = none)]
124        unsafe fn tokenField_menuForRepresentedObject(
125            &self,
126            token_field: &NSTokenField,
127            represented_object: &AnyObject,
128        ) -> Option<Retained<NSMenu>>;
129
130        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
131        /// # Safety
132        ///
133        /// `represented_object` should be of the correct type.
134        #[optional]
135        #[unsafe(method(tokenField:hasMenuForRepresentedObject:))]
136        #[unsafe(method_family = none)]
137        unsafe fn tokenField_hasMenuForRepresentedObject(
138            &self,
139            token_field: &NSTokenField,
140            represented_object: &AnyObject,
141        ) -> bool;
142
143        #[cfg(all(
144            feature = "NSResponder",
145            feature = "NSTokenFieldCell",
146            feature = "NSView"
147        ))]
148        /// # Safety
149        ///
150        /// `represented_object` should be of the correct type.
151        #[optional]
152        #[unsafe(method(tokenField:styleForRepresentedObject:))]
153        #[unsafe(method_family = none)]
154        unsafe fn tokenField_styleForRepresentedObject(
155            &self,
156            token_field: &NSTokenField,
157            represented_object: &AnyObject,
158        ) -> NSTokenStyle;
159    }
160);
161
162extern_class!(
163    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstokenfield?language=objc)
164    #[unsafe(super(NSTextField, NSControl, NSView, NSResponder, NSObject))]
165    #[derive(Debug, PartialEq, Eq, Hash)]
166    #[cfg(all(
167        feature = "NSControl",
168        feature = "NSResponder",
169        feature = "NSTextField",
170        feature = "NSView"
171    ))]
172    pub struct NSTokenField;
173);
174
175#[cfg(all(
176    feature = "NSAccessibilityProtocols",
177    feature = "NSControl",
178    feature = "NSResponder",
179    feature = "NSTextField",
180    feature = "NSView"
181))]
182extern_conformance!(
183    unsafe impl NSAccessibility for NSTokenField {}
184);
185
186#[cfg(all(
187    feature = "NSAccessibilityProtocols",
188    feature = "NSControl",
189    feature = "NSResponder",
190    feature = "NSTextField",
191    feature = "NSView"
192))]
193extern_conformance!(
194    unsafe impl NSAccessibilityElementProtocol for NSTokenField {}
195);
196
197#[cfg(all(
198    feature = "NSAccessibilityProtocols",
199    feature = "NSControl",
200    feature = "NSResponder",
201    feature = "NSTextField",
202    feature = "NSView"
203))]
204extern_conformance!(
205    unsafe impl NSAccessibilityNavigableStaticText for NSTokenField {}
206);
207
208#[cfg(all(
209    feature = "NSAccessibilityProtocols",
210    feature = "NSControl",
211    feature = "NSResponder",
212    feature = "NSTextField",
213    feature = "NSView"
214))]
215extern_conformance!(
216    unsafe impl NSAccessibilityStaticText for NSTokenField {}
217);
218
219#[cfg(all(
220    feature = "NSAnimation",
221    feature = "NSControl",
222    feature = "NSResponder",
223    feature = "NSTextField",
224    feature = "NSView"
225))]
226extern_conformance!(
227    unsafe impl NSAnimatablePropertyContainer for NSTokenField {}
228);
229
230#[cfg(all(
231    feature = "NSAppearance",
232    feature = "NSControl",
233    feature = "NSResponder",
234    feature = "NSTextField",
235    feature = "NSView"
236))]
237extern_conformance!(
238    unsafe impl NSAppearanceCustomization for NSTokenField {}
239);
240
241#[cfg(all(
242    feature = "NSControl",
243    feature = "NSResponder",
244    feature = "NSTextField",
245    feature = "NSView"
246))]
247extern_conformance!(
248    unsafe impl NSCoding for NSTokenField {}
249);
250
251#[cfg(all(
252    feature = "NSControl",
253    feature = "NSDragging",
254    feature = "NSResponder",
255    feature = "NSTextField",
256    feature = "NSView"
257))]
258extern_conformance!(
259    unsafe impl NSDraggingDestination for NSTokenField {}
260);
261
262#[cfg(all(
263    feature = "NSControl",
264    feature = "NSResponder",
265    feature = "NSTextField",
266    feature = "NSView"
267))]
268extern_conformance!(
269    unsafe impl NSObjectProtocol for NSTokenField {}
270);
271
272#[cfg(all(
273    feature = "NSControl",
274    feature = "NSResponder",
275    feature = "NSTextContent",
276    feature = "NSTextField",
277    feature = "NSView"
278))]
279extern_conformance!(
280    unsafe impl NSTextContent for NSTokenField {}
281);
282
283#[cfg(all(
284    feature = "NSControl",
285    feature = "NSResponder",
286    feature = "NSTextField",
287    feature = "NSUserInterfaceItemIdentification",
288    feature = "NSView"
289))]
290extern_conformance!(
291    unsafe impl NSUserInterfaceItemIdentification for NSTokenField {}
292);
293
294#[cfg(all(
295    feature = "NSControl",
296    feature = "NSResponder",
297    feature = "NSTextField",
298    feature = "NSUserInterfaceValidation",
299    feature = "NSView"
300))]
301extern_conformance!(
302    unsafe impl NSUserInterfaceValidations for NSTokenField {}
303);
304
305#[cfg(all(
306    feature = "NSControl",
307    feature = "NSResponder",
308    feature = "NSTextField",
309    feature = "NSView"
310))]
311impl NSTokenField {
312    extern_methods!(
313        #[unsafe(method(delegate))]
314        #[unsafe(method_family = none)]
315        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTokenFieldDelegate>>>;
316
317        /// Setter for [`delegate`][Self::delegate].
318        ///
319        /// This is a [weak property][objc2::topics::weak_property].
320        #[unsafe(method(setDelegate:))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn setDelegate(
323            &self,
324            delegate: Option<&ProtocolObject<dyn NSTokenFieldDelegate>>,
325        );
326
327        #[cfg(feature = "NSTokenFieldCell")]
328        #[unsafe(method(tokenStyle))]
329        #[unsafe(method_family = none)]
330        pub fn tokenStyle(&self) -> NSTokenStyle;
331
332        #[cfg(feature = "NSTokenFieldCell")]
333        /// Setter for [`tokenStyle`][Self::tokenStyle].
334        #[unsafe(method(setTokenStyle:))]
335        #[unsafe(method_family = none)]
336        pub fn setTokenStyle(&self, token_style: NSTokenStyle);
337
338        #[unsafe(method(completionDelay))]
339        #[unsafe(method_family = none)]
340        pub fn completionDelay(&self) -> NSTimeInterval;
341
342        /// Setter for [`completionDelay`][Self::completionDelay].
343        #[unsafe(method(setCompletionDelay:))]
344        #[unsafe(method_family = none)]
345        pub fn setCompletionDelay(&self, completion_delay: NSTimeInterval);
346
347        #[unsafe(method(defaultCompletionDelay))]
348        #[unsafe(method_family = none)]
349        pub fn defaultCompletionDelay(mtm: MainThreadMarker) -> NSTimeInterval;
350
351        #[unsafe(method(tokenizingCharacterSet))]
352        #[unsafe(method_family = none)]
353        pub fn tokenizingCharacterSet(&self) -> Retained<NSCharacterSet>;
354
355        /// Setter for [`tokenizingCharacterSet`][Self::tokenizingCharacterSet].
356        ///
357        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
358        #[unsafe(method(setTokenizingCharacterSet:))]
359        #[unsafe(method_family = none)]
360        pub fn setTokenizingCharacterSet(&self, tokenizing_character_set: Option<&NSCharacterSet>);
361
362        #[unsafe(method(defaultTokenizingCharacterSet))]
363        #[unsafe(method_family = none)]
364        pub fn defaultTokenizingCharacterSet(mtm: MainThreadMarker) -> Retained<NSCharacterSet>;
365    );
366}
367
368/// Methods declared on superclass `NSControl`.
369#[cfg(all(
370    feature = "NSControl",
371    feature = "NSResponder",
372    feature = "NSTextField",
373    feature = "NSView"
374))]
375impl NSTokenField {
376    extern_methods!(
377        #[unsafe(method(initWithFrame:))]
378        #[unsafe(method_family = init)]
379        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
380
381        /// # Safety
382        ///
383        /// `coder` possibly has further requirements.
384        #[unsafe(method(initWithCoder:))]
385        #[unsafe(method_family = init)]
386        pub unsafe fn initWithCoder(
387            this: Allocated<Self>,
388            coder: &NSCoder,
389        ) -> Option<Retained<Self>>;
390    );
391}
392
393/// Methods declared on superclass `NSResponder`.
394#[cfg(all(
395    feature = "NSControl",
396    feature = "NSResponder",
397    feature = "NSTextField",
398    feature = "NSView"
399))]
400impl NSTokenField {
401    extern_methods!(
402        #[unsafe(method(init))]
403        #[unsafe(method_family = init)]
404        pub fn init(this: Allocated<Self>) -> Retained<Self>;
405    );
406}
407
408/// Methods declared on superclass `NSObject`.
409#[cfg(all(
410    feature = "NSControl",
411    feature = "NSResponder",
412    feature = "NSTextField",
413    feature = "NSView"
414))]
415impl NSTokenField {
416    extern_methods!(
417        #[unsafe(method(new))]
418        #[unsafe(method_family = new)]
419        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
420    );
421}