objc2_ui_kit/generated/
UIEvent.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieventtype?language=objc)
10// NS_ENUM
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct UIEventType(pub NSInteger);
14impl UIEventType {
15    #[doc(alias = "UIEventTypeTouches")]
16    pub const Touches: Self = Self(0);
17    #[doc(alias = "UIEventTypeMotion")]
18    pub const Motion: Self = Self(1);
19    #[doc(alias = "UIEventTypeRemoteControl")]
20    pub const RemoteControl: Self = Self(2);
21    #[doc(alias = "UIEventTypePresses")]
22    pub const Presses: Self = Self(3);
23    #[doc(alias = "UIEventTypeScroll")]
24    pub const Scroll: Self = Self(10);
25    #[doc(alias = "UIEventTypeHover")]
26    pub const Hover: Self = Self(11);
27    #[doc(alias = "UIEventTypeTransform")]
28    pub const Transform: Self = Self(14);
29}
30
31unsafe impl Encode for UIEventType {
32    const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for UIEventType {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieventsubtype?language=objc)
40// NS_ENUM
41#[repr(transparent)]
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct UIEventSubtype(pub NSInteger);
44impl UIEventSubtype {
45    #[doc(alias = "UIEventSubtypeNone")]
46    pub const None: Self = Self(0);
47    #[doc(alias = "UIEventSubtypeMotionShake")]
48    pub const MotionShake: Self = Self(1);
49    #[doc(alias = "UIEventSubtypeRemoteControlPlay")]
50    pub const RemoteControlPlay: Self = Self(100);
51    #[doc(alias = "UIEventSubtypeRemoteControlPause")]
52    pub const RemoteControlPause: Self = Self(101);
53    #[doc(alias = "UIEventSubtypeRemoteControlStop")]
54    pub const RemoteControlStop: Self = Self(102);
55    #[doc(alias = "UIEventSubtypeRemoteControlTogglePlayPause")]
56    pub const RemoteControlTogglePlayPause: Self = Self(103);
57    #[doc(alias = "UIEventSubtypeRemoteControlNextTrack")]
58    pub const RemoteControlNextTrack: Self = Self(104);
59    #[doc(alias = "UIEventSubtypeRemoteControlPreviousTrack")]
60    pub const RemoteControlPreviousTrack: Self = Self(105);
61    #[doc(alias = "UIEventSubtypeRemoteControlBeginSeekingBackward")]
62    pub const RemoteControlBeginSeekingBackward: Self = Self(106);
63    #[doc(alias = "UIEventSubtypeRemoteControlEndSeekingBackward")]
64    pub const RemoteControlEndSeekingBackward: Self = Self(107);
65    #[doc(alias = "UIEventSubtypeRemoteControlBeginSeekingForward")]
66    pub const RemoteControlBeginSeekingForward: Self = Self(108);
67    #[doc(alias = "UIEventSubtypeRemoteControlEndSeekingForward")]
68    pub const RemoteControlEndSeekingForward: Self = Self(109);
69}
70
71unsafe impl Encode for UIEventSubtype {
72    const ENCODING: Encoding = NSInteger::ENCODING;
73}
74
75unsafe impl RefEncode for UIEventSubtype {
76    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
77}
78
79/// Set of buttons pressed for the current event
80/// Raw format of: 1
81/// <
82/// <
83/// (buttonNumber - 1)
84/// UIEventButtonMaskPrimary = 1
85/// <
86/// <
87/// 0
88///
89/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uieventbuttonmask?language=objc)
90// NS_OPTIONS
91#[repr(transparent)]
92#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
93pub struct UIEventButtonMask(pub NSInteger);
94bitflags::bitflags! {
95    impl UIEventButtonMask: NSInteger {
96        #[doc(alias = "UIEventButtonMaskPrimary")]
97        const Primary = 1<<0;
98        #[doc(alias = "UIEventButtonMaskSecondary")]
99        const Secondary = 1<<1;
100    }
101}
102
103unsafe impl Encode for UIEventButtonMask {
104    const ENCODING: Encoding = NSInteger::ENCODING;
105}
106
107unsafe impl RefEncode for UIEventButtonMask {
108    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
109}
110
111extern "C-unwind" {
112    /// Convenience initializer for a button mask where `buttonNumber` is a one-based index of the button on the input device
113    /// .button(1) == .primary
114    /// .button(2) == .secondary
115    pub fn UIEventButtonMaskForButtonNumber(button_number: NSInteger) -> UIEventButtonMask;
116}
117
118extern_class!(
119    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uievent?language=objc)
120    #[unsafe(super(NSObject))]
121    #[thread_kind = MainThreadOnly]
122    #[derive(Debug, PartialEq, Eq, Hash)]
123    pub struct UIEvent;
124);
125
126unsafe impl NSObjectProtocol for UIEvent {}
127
128impl UIEvent {
129    extern_methods!(
130        #[unsafe(method(type))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn r#type(&self) -> UIEventType;
133
134        #[unsafe(method(subtype))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn subtype(&self) -> UIEventSubtype;
137
138        #[unsafe(method(timestamp))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn timestamp(&self) -> NSTimeInterval;
141
142        #[cfg(feature = "UICommand")]
143        #[unsafe(method(modifierFlags))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn modifierFlags(&self) -> UIKeyModifierFlags;
146
147        #[unsafe(method(buttonMask))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn buttonMask(&self) -> UIEventButtonMask;
150
151        #[cfg(feature = "UITouch")]
152        #[unsafe(method(allTouches))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn allTouches(&self) -> Option<Retained<NSSet<UITouch>>>;
155
156        #[cfg(all(
157            feature = "UIResponder",
158            feature = "UITouch",
159            feature = "UIView",
160            feature = "UIWindow"
161        ))]
162        #[unsafe(method(touchesForWindow:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn touchesForWindow(
165            &self,
166            window: &UIWindow,
167        ) -> Option<Retained<NSSet<UITouch>>>;
168
169        #[cfg(all(feature = "UIResponder", feature = "UITouch", feature = "UIView"))]
170        #[unsafe(method(touchesForView:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn touchesForView(&self, view: &UIView) -> Option<Retained<NSSet<UITouch>>>;
173
174        #[cfg(all(feature = "UIGestureRecognizer", feature = "UITouch"))]
175        #[unsafe(method(touchesForGestureRecognizer:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn touchesForGestureRecognizer(
178            &self,
179            gesture: &UIGestureRecognizer,
180        ) -> Option<Retained<NSSet<UITouch>>>;
181
182        #[cfg(feature = "UITouch")]
183        #[unsafe(method(coalescedTouchesForTouch:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn coalescedTouchesForTouch(
186            &self,
187            touch: &UITouch,
188        ) -> Option<Retained<NSArray<UITouch>>>;
189
190        #[cfg(feature = "UITouch")]
191        #[unsafe(method(predictedTouchesForTouch:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn predictedTouchesForTouch(
194            &self,
195            touch: &UITouch,
196        ) -> Option<Retained<NSArray<UITouch>>>;
197    );
198}
199
200/// Methods declared on superclass `NSObject`.
201impl UIEvent {
202    extern_methods!(
203        #[unsafe(method(init))]
204        #[unsafe(method_family = init)]
205        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
206
207        #[unsafe(method(new))]
208        #[unsafe(method_family = new)]
209        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
210    );
211}