objc2_app_kit/generated/
NSGestureRecognizer.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[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 #[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:))]
63 #[unsafe(method_family = init)]
64 pub unsafe fn initWithTarget_action(
65 this: Allocated<Self>,
66 target: Option<&AnyObject>,
67 action: Option<Sel>,
68 ) -> Retained<Self>;
69
70 #[unsafe(method(initWithCoder:))]
74 #[unsafe(method_family = init)]
75 pub unsafe fn initWithCoder(
76 this: Allocated<Self>,
77 coder: &NSCoder,
78 ) -> Option<Retained<Self>>;
79
80 #[unsafe(method(target))]
81 #[unsafe(method_family = none)]
82 pub fn target(&self) -> Option<Retained<AnyObject>>;
83
84 #[unsafe(method(setTarget:))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
94
95 #[unsafe(method(action))]
96 #[unsafe(method_family = none)]
97 pub fn action(&self) -> Option<Sel>;
98
99 #[unsafe(method(setAction:))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn setAction(&self, action: Option<Sel>);
107
108 #[unsafe(method(delegate))]
109 #[unsafe(method_family = none)]
110 pub fn delegate(&self)
111 -> Option<Retained<ProtocolObject<dyn NSGestureRecognizerDelegate>>>;
112
113 #[unsafe(method(setDelegate:))]
117 #[unsafe(method_family = none)]
118 pub fn setDelegate(
119 &self,
120 delegate: Option<&ProtocolObject<dyn NSGestureRecognizerDelegate>>,
121 );
122
123 #[unsafe(method(isEnabled))]
124 #[unsafe(method_family = none)]
125 pub fn isEnabled(&self) -> bool;
126
127 #[unsafe(method(setEnabled:))]
129 #[unsafe(method_family = none)]
130 pub fn setEnabled(&self, enabled: bool);
131
132 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
133 #[unsafe(method(view))]
134 #[unsafe(method_family = none)]
135 pub fn view(&self) -> Option<Retained<NSView>>;
136
137 #[cfg(feature = "NSPressureConfiguration")]
138 #[unsafe(method(pressureConfiguration))]
139 #[unsafe(method_family = none)]
140 pub fn pressureConfiguration(&self) -> Retained<NSPressureConfiguration>;
141
142 #[cfg(feature = "NSPressureConfiguration")]
143 #[unsafe(method(setPressureConfiguration:))]
145 #[unsafe(method_family = none)]
146 pub fn setPressureConfiguration(&self, pressure_configuration: &NSPressureConfiguration);
147
148 #[unsafe(method(delaysPrimaryMouseButtonEvents))]
149 #[unsafe(method_family = none)]
150 pub fn delaysPrimaryMouseButtonEvents(&self) -> bool;
151
152 #[unsafe(method(setDelaysPrimaryMouseButtonEvents:))]
154 #[unsafe(method_family = none)]
155 pub fn setDelaysPrimaryMouseButtonEvents(&self, delays_primary_mouse_button_events: bool);
156
157 #[unsafe(method(delaysSecondaryMouseButtonEvents))]
158 #[unsafe(method_family = none)]
159 pub fn delaysSecondaryMouseButtonEvents(&self) -> bool;
160
161 #[unsafe(method(setDelaysSecondaryMouseButtonEvents:))]
163 #[unsafe(method_family = none)]
164 pub fn setDelaysSecondaryMouseButtonEvents(
165 &self,
166 delays_secondary_mouse_button_events: bool,
167 );
168
169 #[unsafe(method(delaysOtherMouseButtonEvents))]
170 #[unsafe(method_family = none)]
171 pub fn delaysOtherMouseButtonEvents(&self) -> bool;
172
173 #[unsafe(method(setDelaysOtherMouseButtonEvents:))]
175 #[unsafe(method_family = none)]
176 pub fn setDelaysOtherMouseButtonEvents(&self, delays_other_mouse_button_events: bool);
177
178 #[unsafe(method(delaysKeyEvents))]
179 #[unsafe(method_family = none)]
180 pub fn delaysKeyEvents(&self) -> bool;
181
182 #[unsafe(method(setDelaysKeyEvents:))]
184 #[unsafe(method_family = none)]
185 pub fn setDelaysKeyEvents(&self, delays_key_events: bool);
186
187 #[unsafe(method(delaysMagnificationEvents))]
188 #[unsafe(method_family = none)]
189 pub fn delaysMagnificationEvents(&self) -> bool;
190
191 #[unsafe(method(setDelaysMagnificationEvents:))]
193 #[unsafe(method_family = none)]
194 pub fn setDelaysMagnificationEvents(&self, delays_magnification_events: bool);
195
196 #[unsafe(method(delaysRotationEvents))]
197 #[unsafe(method_family = none)]
198 pub fn delaysRotationEvents(&self) -> bool;
199
200 #[unsafe(method(setDelaysRotationEvents:))]
202 #[unsafe(method_family = none)]
203 pub fn setDelaysRotationEvents(&self, delays_rotation_events: bool);
204
205 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
206 #[unsafe(method(locationInView:))]
207 #[unsafe(method_family = none)]
208 pub fn locationInView(&self, view: Option<&NSView>) -> NSPoint;
209
210 #[unsafe(method(name))]
211 #[unsafe(method_family = none)]
212 pub fn name(&self) -> Option<Retained<NSString>>;
213
214 #[unsafe(method(setName:))]
218 #[unsafe(method_family = none)]
219 pub fn setName(&self, name: Option<&NSString>);
220
221 #[cfg(feature = "NSEvent")]
222 #[unsafe(method(modifierFlags))]
223 #[unsafe(method_family = none)]
224 pub fn modifierFlags(&self) -> NSEventModifierFlags;
225 );
226}
227
228impl NSGestureRecognizer {
230 extern_methods!(
231 #[unsafe(method(init))]
232 #[unsafe(method_family = init)]
233 pub fn init(this: Allocated<Self>) -> Retained<Self>;
234
235 #[unsafe(method(new))]
236 #[unsafe(method_family = new)]
237 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
238 );
239}
240
241impl NSGestureRecognizer {
243 extern_methods!(
244 #[cfg(feature = "NSTouch")]
245 #[unsafe(method(allowedTouchTypes))]
246 #[unsafe(method_family = none)]
247 pub fn allowedTouchTypes(&self) -> NSTouchTypeMask;
248
249 #[cfg(feature = "NSTouch")]
250 #[unsafe(method(setAllowedTouchTypes:))]
252 #[unsafe(method_family = none)]
253 pub fn setAllowedTouchTypes(&self, allowed_touch_types: NSTouchTypeMask);
254 );
255}
256
257extern_protocol!(
258 pub unsafe trait NSGestureRecognizerDelegate: NSObjectProtocol + MainThreadOnly {
260 #[cfg(feature = "NSEvent")]
261 #[optional]
262 #[unsafe(method(gestureRecognizer:shouldAttemptToRecognizeWithEvent:))]
263 #[unsafe(method_family = none)]
264 fn gestureRecognizer_shouldAttemptToRecognizeWithEvent(
265 &self,
266 gesture_recognizer: &NSGestureRecognizer,
267 event: &NSEvent,
268 ) -> bool;
269
270 #[optional]
271 #[unsafe(method(gestureRecognizerShouldBegin:))]
272 #[unsafe(method_family = none)]
273 fn gestureRecognizerShouldBegin(&self, gesture_recognizer: &NSGestureRecognizer) -> bool;
274
275 #[optional]
276 #[unsafe(method(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:))]
277 #[unsafe(method_family = none)]
278 fn gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer(
279 &self,
280 gesture_recognizer: &NSGestureRecognizer,
281 other_gesture_recognizer: &NSGestureRecognizer,
282 ) -> bool;
283
284 #[optional]
285 #[unsafe(method(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:))]
286 #[unsafe(method_family = none)]
287 fn gestureRecognizer_shouldRequireFailureOfGestureRecognizer(
288 &self,
289 gesture_recognizer: &NSGestureRecognizer,
290 other_gesture_recognizer: &NSGestureRecognizer,
291 ) -> bool;
292
293 #[optional]
294 #[unsafe(method(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:))]
295 #[unsafe(method_family = none)]
296 fn gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer(
297 &self,
298 gesture_recognizer: &NSGestureRecognizer,
299 other_gesture_recognizer: &NSGestureRecognizer,
300 ) -> bool;
301
302 #[cfg(feature = "NSTouch")]
303 #[optional]
304 #[unsafe(method(gestureRecognizer:shouldReceiveTouch:))]
305 #[unsafe(method_family = none)]
306 fn gestureRecognizer_shouldReceiveTouch(
307 &self,
308 gesture_recognizer: &NSGestureRecognizer,
309 touch: &NSTouch,
310 ) -> bool;
311 }
312);
313
314impl NSGestureRecognizer {
316 extern_methods!(
317 #[unsafe(method(setState:))]
319 #[unsafe(method_family = none)]
320 pub fn setState(&self, state: NSGestureRecognizerState);
321
322 #[unsafe(method(reset))]
323 #[unsafe(method_family = none)]
324 pub fn reset(&self);
325
326 #[unsafe(method(canPreventGestureRecognizer:))]
327 #[unsafe(method_family = none)]
328 pub fn canPreventGestureRecognizer(
329 &self,
330 prevented_gesture_recognizer: &NSGestureRecognizer,
331 ) -> bool;
332
333 #[unsafe(method(canBePreventedByGestureRecognizer:))]
334 #[unsafe(method_family = none)]
335 pub fn canBePreventedByGestureRecognizer(
336 &self,
337 preventing_gesture_recognizer: &NSGestureRecognizer,
338 ) -> bool;
339
340 #[unsafe(method(shouldRequireFailureOfGestureRecognizer:))]
341 #[unsafe(method_family = none)]
342 pub fn shouldRequireFailureOfGestureRecognizer(
343 &self,
344 other_gesture_recognizer: &NSGestureRecognizer,
345 ) -> bool;
346
347 #[unsafe(method(shouldBeRequiredToFailByGestureRecognizer:))]
348 #[unsafe(method_family = none)]
349 pub fn shouldBeRequiredToFailByGestureRecognizer(
350 &self,
351 other_gesture_recognizer: &NSGestureRecognizer,
352 ) -> bool;
353
354 #[cfg(feature = "NSEvent")]
355 #[unsafe(method(mouseDown:))]
356 #[unsafe(method_family = none)]
357 pub fn mouseDown(&self, event: &NSEvent);
358
359 #[cfg(feature = "NSEvent")]
360 #[unsafe(method(rightMouseDown:))]
361 #[unsafe(method_family = none)]
362 pub fn rightMouseDown(&self, event: &NSEvent);
363
364 #[cfg(feature = "NSEvent")]
365 #[unsafe(method(otherMouseDown:))]
366 #[unsafe(method_family = none)]
367 pub fn otherMouseDown(&self, event: &NSEvent);
368
369 #[cfg(feature = "NSEvent")]
370 #[unsafe(method(mouseUp:))]
371 #[unsafe(method_family = none)]
372 pub fn mouseUp(&self, event: &NSEvent);
373
374 #[cfg(feature = "NSEvent")]
375 #[unsafe(method(rightMouseUp:))]
376 #[unsafe(method_family = none)]
377 pub fn rightMouseUp(&self, event: &NSEvent);
378
379 #[cfg(feature = "NSEvent")]
380 #[unsafe(method(otherMouseUp:))]
381 #[unsafe(method_family = none)]
382 pub fn otherMouseUp(&self, event: &NSEvent);
383
384 #[cfg(feature = "NSEvent")]
385 #[unsafe(method(mouseDragged:))]
386 #[unsafe(method_family = none)]
387 pub fn mouseDragged(&self, event: &NSEvent);
388
389 #[cfg(feature = "NSEvent")]
390 #[unsafe(method(rightMouseDragged:))]
391 #[unsafe(method_family = none)]
392 pub fn rightMouseDragged(&self, event: &NSEvent);
393
394 #[cfg(feature = "NSEvent")]
395 #[unsafe(method(otherMouseDragged:))]
396 #[unsafe(method_family = none)]
397 pub fn otherMouseDragged(&self, event: &NSEvent);
398
399 #[cfg(feature = "NSEvent")]
400 #[unsafe(method(mouseCancelled:))]
401 #[unsafe(method_family = none)]
402 pub fn mouseCancelled(&self, event: &NSEvent);
403
404 #[cfg(feature = "NSEvent")]
405 #[unsafe(method(keyDown:))]
406 #[unsafe(method_family = none)]
407 pub fn keyDown(&self, event: &NSEvent);
408
409 #[cfg(feature = "NSEvent")]
410 #[unsafe(method(keyUp:))]
411 #[unsafe(method_family = none)]
412 pub fn keyUp(&self, event: &NSEvent);
413
414 #[cfg(feature = "NSEvent")]
415 #[unsafe(method(flagsChanged:))]
416 #[unsafe(method_family = none)]
417 pub fn flagsChanged(&self, event: &NSEvent);
418
419 #[cfg(feature = "NSEvent")]
420 #[unsafe(method(tabletPoint:))]
421 #[unsafe(method_family = none)]
422 pub fn tabletPoint(&self, event: &NSEvent);
423
424 #[cfg(feature = "NSEvent")]
425 #[unsafe(method(magnifyWithEvent:))]
426 #[unsafe(method_family = none)]
427 pub fn magnifyWithEvent(&self, event: &NSEvent);
428
429 #[cfg(feature = "NSEvent")]
430 #[unsafe(method(rotateWithEvent:))]
431 #[unsafe(method_family = none)]
432 pub fn rotateWithEvent(&self, event: &NSEvent);
433
434 #[cfg(feature = "NSEvent")]
435 #[unsafe(method(pressureChangeWithEvent:))]
436 #[unsafe(method_family = none)]
437 pub fn pressureChangeWithEvent(&self, event: &NSEvent);
438
439 #[cfg(feature = "NSEvent")]
440 #[unsafe(method(touchesBeganWithEvent:))]
441 #[unsafe(method_family = none)]
442 pub fn touchesBeganWithEvent(&self, event: &NSEvent);
443
444 #[cfg(feature = "NSEvent")]
445 #[unsafe(method(touchesMovedWithEvent:))]
446 #[unsafe(method_family = none)]
447 pub fn touchesMovedWithEvent(&self, event: &NSEvent);
448
449 #[cfg(feature = "NSEvent")]
450 #[unsafe(method(touchesEndedWithEvent:))]
451 #[unsafe(method_family = none)]
452 pub fn touchesEndedWithEvent(&self, event: &NSEvent);
453
454 #[cfg(feature = "NSEvent")]
455 #[unsafe(method(touchesCancelledWithEvent:))]
456 #[unsafe(method_family = none)]
457 pub fn touchesCancelledWithEvent(&self, event: &NSEvent);
458 );
459}