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