objc2_ui_kit/generated/
UIEvent.rs1use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9#[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#[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#[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 pub fn UIEventButtonMaskForButtonNumber(button_number: NSInteger) -> UIEventButtonMask;
116}
117
118extern_class!(
119 #[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
200impl 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}