objc2_app_kit/generated/
NSGestureRecognizer.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
10/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgesturerecognizerstate?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSGestureRecognizerState(pub NSInteger);
15impl NSGestureRecognizerState {
16    #[doc(alias = "NSGestureRecognizerStatePossible")]
17    pub const Possible: Self = Self(0);
18    #[doc(alias = "NSGestureRecognizerStateBegan")]
19    pub const Began: Self = Self(1);
20    #[doc(alias = "NSGestureRecognizerStateChanged")]
21    pub const Changed: Self = Self(2);
22    #[doc(alias = "NSGestureRecognizerStateEnded")]
23    pub const Ended: Self = Self(3);
24    #[doc(alias = "NSGestureRecognizerStateCancelled")]
25    pub const Cancelled: Self = Self(4);
26    #[doc(alias = "NSGestureRecognizerStateFailed")]
27    pub const Failed: Self = Self(5);
28    #[doc(alias = "NSGestureRecognizerStateRecognized")]
29    pub const Recognized: Self = Self(NSGestureRecognizerState::Ended.0);
30}
31
32unsafe impl Encode for NSGestureRecognizerState {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for NSGestureRecognizerState {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgesturerecognizer?language=objc)
42    #[unsafe(super(NSObject))]
43    #[thread_kind = MainThreadOnly]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    pub struct NSGestureRecognizer;
46);
47
48extern_conformance!(
49    unsafe impl NSCoding for NSGestureRecognizer {}
50);
51
52extern_conformance!(
53    unsafe impl NSObjectProtocol for NSGestureRecognizer {}
54);
55
56impl NSGestureRecognizer {
57    extern_methods!(
58        #[unsafe(method(initWithTarget:action:))]
59        #[unsafe(method_family = init)]
60        pub unsafe fn initWithTarget_action(
61            this: Allocated<Self>,
62            target: Option<&AnyObject>,
63            action: Option<Sel>,
64        ) -> Retained<Self>;
65
66        #[unsafe(method(initWithCoder:))]
67        #[unsafe(method_family = init)]
68        pub unsafe fn initWithCoder(
69            this: Allocated<Self>,
70            coder: &NSCoder,
71        ) -> Option<Retained<Self>>;
72
73        #[unsafe(method(target))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn target(&self) -> Option<Retained<AnyObject>>;
76
77        /// This is a [weak property][objc2::topics::weak_property].
78        /// Setter for [`target`][Self::target].
79        #[unsafe(method(setTarget:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
82
83        #[unsafe(method(action))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn action(&self) -> Option<Sel>;
86
87        /// Setter for [`action`][Self::action].
88        #[unsafe(method(setAction:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn setAction(&self, action: Option<Sel>);
91
92        #[unsafe(method(delegate))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn delegate(
95            &self,
96        ) -> Option<Retained<ProtocolObject<dyn NSGestureRecognizerDelegate>>>;
97
98        /// This is a [weak property][objc2::topics::weak_property].
99        /// Setter for [`delegate`][Self::delegate].
100        #[unsafe(method(setDelegate:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn setDelegate(
103            &self,
104            delegate: Option<&ProtocolObject<dyn NSGestureRecognizerDelegate>>,
105        );
106
107        #[unsafe(method(isEnabled))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn isEnabled(&self) -> bool;
110
111        /// Setter for [`isEnabled`][Self::isEnabled].
112        #[unsafe(method(setEnabled:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn setEnabled(&self, enabled: bool);
115
116        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
117        #[unsafe(method(view))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn view(&self) -> Option<Retained<NSView>>;
120
121        #[cfg(feature = "NSPressureConfiguration")]
122        #[unsafe(method(pressureConfiguration))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn pressureConfiguration(&self) -> Retained<NSPressureConfiguration>;
125
126        #[cfg(feature = "NSPressureConfiguration")]
127        /// Setter for [`pressureConfiguration`][Self::pressureConfiguration].
128        #[unsafe(method(setPressureConfiguration:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setPressureConfiguration(
131            &self,
132            pressure_configuration: &NSPressureConfiguration,
133        );
134
135        #[unsafe(method(delaysPrimaryMouseButtonEvents))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn delaysPrimaryMouseButtonEvents(&self) -> bool;
138
139        /// Setter for [`delaysPrimaryMouseButtonEvents`][Self::delaysPrimaryMouseButtonEvents].
140        #[unsafe(method(setDelaysPrimaryMouseButtonEvents:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setDelaysPrimaryMouseButtonEvents(
143            &self,
144            delays_primary_mouse_button_events: bool,
145        );
146
147        #[unsafe(method(delaysSecondaryMouseButtonEvents))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn delaysSecondaryMouseButtonEvents(&self) -> bool;
150
151        /// Setter for [`delaysSecondaryMouseButtonEvents`][Self::delaysSecondaryMouseButtonEvents].
152        #[unsafe(method(setDelaysSecondaryMouseButtonEvents:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn setDelaysSecondaryMouseButtonEvents(
155            &self,
156            delays_secondary_mouse_button_events: bool,
157        );
158
159        #[unsafe(method(delaysOtherMouseButtonEvents))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn delaysOtherMouseButtonEvents(&self) -> bool;
162
163        /// Setter for [`delaysOtherMouseButtonEvents`][Self::delaysOtherMouseButtonEvents].
164        #[unsafe(method(setDelaysOtherMouseButtonEvents:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setDelaysOtherMouseButtonEvents(
167            &self,
168            delays_other_mouse_button_events: bool,
169        );
170
171        #[unsafe(method(delaysKeyEvents))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn delaysKeyEvents(&self) -> bool;
174
175        /// Setter for [`delaysKeyEvents`][Self::delaysKeyEvents].
176        #[unsafe(method(setDelaysKeyEvents:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setDelaysKeyEvents(&self, delays_key_events: bool);
179
180        #[unsafe(method(delaysMagnificationEvents))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn delaysMagnificationEvents(&self) -> bool;
183
184        /// Setter for [`delaysMagnificationEvents`][Self::delaysMagnificationEvents].
185        #[unsafe(method(setDelaysMagnificationEvents:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn setDelaysMagnificationEvents(&self, delays_magnification_events: bool);
188
189        #[unsafe(method(delaysRotationEvents))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn delaysRotationEvents(&self) -> bool;
192
193        /// Setter for [`delaysRotationEvents`][Self::delaysRotationEvents].
194        #[unsafe(method(setDelaysRotationEvents:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn setDelaysRotationEvents(&self, delays_rotation_events: bool);
197
198        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
199        #[unsafe(method(locationInView:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn locationInView(&self, view: Option<&NSView>) -> NSPoint;
202    );
203}
204
205/// Methods declared on superclass `NSObject`.
206impl NSGestureRecognizer {
207    extern_methods!(
208        #[unsafe(method(init))]
209        #[unsafe(method_family = init)]
210        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
211
212        #[unsafe(method(new))]
213        #[unsafe(method_family = new)]
214        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
215    );
216}
217
218/// NSTouchBar.
219impl NSGestureRecognizer {
220    extern_methods!(
221        #[cfg(feature = "NSTouch")]
222        #[unsafe(method(allowedTouchTypes))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn allowedTouchTypes(&self) -> NSTouchTypeMask;
225
226        #[cfg(feature = "NSTouch")]
227        /// Setter for [`allowedTouchTypes`][Self::allowedTouchTypes].
228        #[unsafe(method(setAllowedTouchTypes:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn setAllowedTouchTypes(&self, allowed_touch_types: NSTouchTypeMask);
231    );
232}
233
234extern_protocol!(
235    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgesturerecognizerdelegate?language=objc)
236    pub unsafe trait NSGestureRecognizerDelegate: NSObjectProtocol + MainThreadOnly {
237        #[cfg(feature = "NSEvent")]
238        #[optional]
239        #[unsafe(method(gestureRecognizer:shouldAttemptToRecognizeWithEvent:))]
240        #[unsafe(method_family = none)]
241        unsafe fn gestureRecognizer_shouldAttemptToRecognizeWithEvent(
242            &self,
243            gesture_recognizer: &NSGestureRecognizer,
244            event: &NSEvent,
245        ) -> bool;
246
247        #[optional]
248        #[unsafe(method(gestureRecognizerShouldBegin:))]
249        #[unsafe(method_family = none)]
250        unsafe fn gestureRecognizerShouldBegin(
251            &self,
252            gesture_recognizer: &NSGestureRecognizer,
253        ) -> bool;
254
255        #[optional]
256        #[unsafe(method(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:))]
257        #[unsafe(method_family = none)]
258        unsafe fn gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer(
259            &self,
260            gesture_recognizer: &NSGestureRecognizer,
261            other_gesture_recognizer: &NSGestureRecognizer,
262        ) -> bool;
263
264        #[optional]
265        #[unsafe(method(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:))]
266        #[unsafe(method_family = none)]
267        unsafe fn gestureRecognizer_shouldRequireFailureOfGestureRecognizer(
268            &self,
269            gesture_recognizer: &NSGestureRecognizer,
270            other_gesture_recognizer: &NSGestureRecognizer,
271        ) -> bool;
272
273        #[optional]
274        #[unsafe(method(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:))]
275        #[unsafe(method_family = none)]
276        unsafe fn gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer(
277            &self,
278            gesture_recognizer: &NSGestureRecognizer,
279            other_gesture_recognizer: &NSGestureRecognizer,
280        ) -> bool;
281
282        #[cfg(feature = "NSTouch")]
283        #[optional]
284        #[unsafe(method(gestureRecognizer:shouldReceiveTouch:))]
285        #[unsafe(method_family = none)]
286        unsafe fn gestureRecognizer_shouldReceiveTouch(
287            &self,
288            gesture_recognizer: &NSGestureRecognizer,
289            touch: &NSTouch,
290        ) -> bool;
291    }
292);
293
294/// NSSubclassUse.
295impl NSGestureRecognizer {
296    extern_methods!(
297        /// Setter for [`state`][Self::state].
298        #[unsafe(method(setState:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn setState(&self, state: NSGestureRecognizerState);
301
302        #[unsafe(method(reset))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn reset(&self);
305
306        #[unsafe(method(canPreventGestureRecognizer:))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn canPreventGestureRecognizer(
309            &self,
310            prevented_gesture_recognizer: &NSGestureRecognizer,
311        ) -> bool;
312
313        #[unsafe(method(canBePreventedByGestureRecognizer:))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn canBePreventedByGestureRecognizer(
316            &self,
317            preventing_gesture_recognizer: &NSGestureRecognizer,
318        ) -> bool;
319
320        #[unsafe(method(shouldRequireFailureOfGestureRecognizer:))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn shouldRequireFailureOfGestureRecognizer(
323            &self,
324            other_gesture_recognizer: &NSGestureRecognizer,
325        ) -> bool;
326
327        #[unsafe(method(shouldBeRequiredToFailByGestureRecognizer:))]
328        #[unsafe(method_family = none)]
329        pub unsafe fn shouldBeRequiredToFailByGestureRecognizer(
330            &self,
331            other_gesture_recognizer: &NSGestureRecognizer,
332        ) -> bool;
333
334        #[cfg(feature = "NSEvent")]
335        #[unsafe(method(mouseDown:))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn mouseDown(&self, event: &NSEvent);
338
339        #[cfg(feature = "NSEvent")]
340        #[unsafe(method(rightMouseDown:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn rightMouseDown(&self, event: &NSEvent);
343
344        #[cfg(feature = "NSEvent")]
345        #[unsafe(method(otherMouseDown:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn otherMouseDown(&self, event: &NSEvent);
348
349        #[cfg(feature = "NSEvent")]
350        #[unsafe(method(mouseUp:))]
351        #[unsafe(method_family = none)]
352        pub unsafe fn mouseUp(&self, event: &NSEvent);
353
354        #[cfg(feature = "NSEvent")]
355        #[unsafe(method(rightMouseUp:))]
356        #[unsafe(method_family = none)]
357        pub unsafe fn rightMouseUp(&self, event: &NSEvent);
358
359        #[cfg(feature = "NSEvent")]
360        #[unsafe(method(otherMouseUp:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn otherMouseUp(&self, event: &NSEvent);
363
364        #[cfg(feature = "NSEvent")]
365        #[unsafe(method(mouseDragged:))]
366        #[unsafe(method_family = none)]
367        pub unsafe fn mouseDragged(&self, event: &NSEvent);
368
369        #[cfg(feature = "NSEvent")]
370        #[unsafe(method(rightMouseDragged:))]
371        #[unsafe(method_family = none)]
372        pub unsafe fn rightMouseDragged(&self, event: &NSEvent);
373
374        #[cfg(feature = "NSEvent")]
375        #[unsafe(method(otherMouseDragged:))]
376        #[unsafe(method_family = none)]
377        pub unsafe fn otherMouseDragged(&self, event: &NSEvent);
378
379        #[cfg(feature = "NSEvent")]
380        #[unsafe(method(keyDown:))]
381        #[unsafe(method_family = none)]
382        pub unsafe fn keyDown(&self, event: &NSEvent);
383
384        #[cfg(feature = "NSEvent")]
385        #[unsafe(method(keyUp:))]
386        #[unsafe(method_family = none)]
387        pub unsafe fn keyUp(&self, event: &NSEvent);
388
389        #[cfg(feature = "NSEvent")]
390        #[unsafe(method(flagsChanged:))]
391        #[unsafe(method_family = none)]
392        pub unsafe fn flagsChanged(&self, event: &NSEvent);
393
394        #[cfg(feature = "NSEvent")]
395        #[unsafe(method(tabletPoint:))]
396        #[unsafe(method_family = none)]
397        pub unsafe fn tabletPoint(&self, event: &NSEvent);
398
399        #[cfg(feature = "NSEvent")]
400        #[unsafe(method(magnifyWithEvent:))]
401        #[unsafe(method_family = none)]
402        pub unsafe fn magnifyWithEvent(&self, event: &NSEvent);
403
404        #[cfg(feature = "NSEvent")]
405        #[unsafe(method(rotateWithEvent:))]
406        #[unsafe(method_family = none)]
407        pub unsafe fn rotateWithEvent(&self, event: &NSEvent);
408
409        #[cfg(feature = "NSEvent")]
410        #[unsafe(method(pressureChangeWithEvent:))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn pressureChangeWithEvent(&self, event: &NSEvent);
413
414        #[cfg(feature = "NSEvent")]
415        #[unsafe(method(touchesBeganWithEvent:))]
416        #[unsafe(method_family = none)]
417        pub unsafe fn touchesBeganWithEvent(&self, event: &NSEvent);
418
419        #[cfg(feature = "NSEvent")]
420        #[unsafe(method(touchesMovedWithEvent:))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn touchesMovedWithEvent(&self, event: &NSEvent);
423
424        #[cfg(feature = "NSEvent")]
425        #[unsafe(method(touchesEndedWithEvent:))]
426        #[unsafe(method_family = none)]
427        pub unsafe fn touchesEndedWithEvent(&self, event: &NSEvent);
428
429        #[cfg(feature = "NSEvent")]
430        #[unsafe(method(touchesCancelledWithEvent:))]
431        #[unsafe(method_family = none)]
432        pub unsafe fn touchesCancelledWithEvent(&self, event: &NSEvent);
433    );
434}