3
using System.Diagnostics;
4
using MonoMac.Foundation;
5
using MonoMac.CoreGraphics;
7
namespace MonoMac.AppKit {
9
[DebuggerTypeProxy (typeof(NSEvent.NSEventDebuggerProxy))]
10
public partial class NSEvent {
12
class NSEventDebuggerProxy {
15
public NSEventDebuggerProxy (NSEvent target)
20
#region Generic Event Information
23
internal NSGraphicsContext Context {
25
return target.Context;
29
public PointF LocationInWindow {
31
return target.LocationInWindow;
35
public NSEventModifierMask ModifierFlags {
37
return target.ModifierFlags;
41
public double Timestamp {
43
return target.Timestamp;
47
public NSEventType Type {
53
public NSWindow Window {
59
public int WindowNumber {
61
return target.WindowNumber;
65
public IntPtr CGEvent {
67
return target.CGEvent;
73
#region Key Event Information
77
switch (target.Type) {
78
case NSEventType.KeyDown:
79
case NSEventType.KeyUp:
90
throw new InvalidOperationException ("Not a key event.");
93
public string Characters {
96
return target.Characters;
100
public string CharactersIgnoringModifiers {
103
return target.CharactersIgnoringModifiers;
107
public bool IsARepeat {
110
return target.IsARepeat;
114
public ushort KeyCode {
117
return target.KeyCode;
123
#region Tablet Pointing Information
125
const int TabletPointEventSubtype = 1;
126
const int TabletProximityEventSubtype = 2;
130
switch (target.Type) {
131
case NSEventType.LeftMouseDown:
132
case NSEventType.LeftMouseUp:
133
case NSEventType.RightMouseDown:
134
case NSEventType.RightMouseUp:
135
case NSEventType.MouseMoved:
136
case NSEventType.LeftMouseDragged:
137
case NSEventType.RightMouseDragged:
138
case NSEventType.MouseEntered:
139
case NSEventType.MouseExited:
140
case NSEventType.OtherMouseDown:
141
case NSEventType.OtherMouseUp:
142
case NSEventType.OtherMouseDragged:
149
bool IsTabletPointingEvent ()
152
return target.Subtype == TabletPointEventSubtype;
153
return target.Type == NSEventType.TabletPoint;
156
void CheckTabletPointingEvent ()
158
if (IsTabletPointingEvent ())
160
throw new InvalidOperationException ("Not a tablet pointing event.");
163
public int AbsoluteX {
165
CheckTabletPointingEvent ();
166
return target.AbsoluteX;
170
public int AbsoluteY {
172
CheckTabletPointingEvent ();
173
return target.AbsoluteY;
177
public int AbsoluteZ {
179
CheckTabletPointingEvent ();
180
return target.AbsoluteZ;
184
public uint ButtonMask {
186
CheckTabletPointingEvent ();
187
return target.ButtonMask;
191
public float Rotation {
193
CheckTabletPointingEvent ();
194
return target.Rotation;
198
public float TangentialPressure {
200
CheckTabletPointingEvent ();
201
return target.TangentialPressure;
207
CheckTabletPointingEvent ();
212
public NSObject VendorDefined {
214
CheckTabletPointingEvent ();
215
return target.VendorDefined;
221
#region Mouse Event Information
223
void CheckMouseEvent ()
227
throw new InvalidOperationException ("Not a mouse event.");
230
public int ButtonNumber {
233
return target.ButtonNumber;
237
public int ClickCount {
240
return target.ClickCount;
244
public float Pressure {
247
return target.Pressure;
253
#region Mouse Tracking Event Information
255
bool IsMouseTrackingEvent ()
261
void CheckMouseTrackingEvent ()
263
if (IsMouseTrackingEvent ())
265
throw new InvalidOperationException ("Not a mouse tracking event.");
268
internal int EventNumber {
270
CheckMouseTrackingEvent ();
271
return target.EventNumber;
275
internal int TrackingNumber {
277
CheckMouseTrackingEvent ();
278
return target.TrackingNumber;
282
internal NSTrackingArea TrackingArea {
284
CheckMouseTrackingEvent ();
285
return target.TrackingArea;
289
internal IntPtr UserData {
291
CheckMouseTrackingEvent ();
292
return target.UserData;
298
#region Custom Event Information
300
bool IsCustomEvent ()
302
switch (target.Type) {
303
case NSEventType.AppKitDefined:
304
case NSEventType.SystemDefined:
305
case NSEventType.ApplicationDefined:
306
case NSEventType.Periodic:
313
void CheckCustomEvent ()
315
if (IsCustomEvent ())
317
throw new InvalidOperationException ("Not a custom event.");
320
public short Subtype {
323
return target.Subtype;
343
#region Scroll Wheel Event Information
345
bool IsScrollWheelEvent ()
347
switch (target.Type) {
348
case NSEventType.ScrollWheel:
355
void CheckScrollWheelEvent ()
357
if (IsScrollWheelEvent ())
359
throw new InvalidOperationException ("Not a scroll wheel event.");
362
public float DeltaX {
364
CheckScrollWheelEvent ();
369
public float DeltaY {
371
CheckScrollWheelEvent ();
376
public float DeltaZ {
378
CheckScrollWheelEvent ();
385
#region Tablet Proximity Information
387
bool IsTabletProximityEvent ()
390
return target.Subtype == TabletProximityEventSubtype;
391
return target.Type == NSEventType.TabletProximity;
394
void CheckTabletProximityEvent ()
396
if (IsTabletProximityEvent ())
398
throw new InvalidOperationException ("Not a tablet proximity event.");
401
public uint CapabilityMask {
403
CheckTabletProximityEvent ();
404
return target.CapabilityMask;
408
public uint DeviceID {
410
CheckTabletProximityEvent ();
411
return target.DeviceID;
415
public bool IsEnteringProximity {
417
CheckTabletProximityEvent ();
418
return target.IsEnteringProximity;
422
public uint PointingDeviceSerialNumber {
424
CheckTabletProximityEvent ();
425
return target.PointingDeviceSerialNumber;
429
public uint PointingDeviceID {
431
CheckTabletProximityEvent ();
432
return target.PointingDeviceID ();
436
public NSPointingDeviceType PointingDeviceType {
438
CheckTabletProximityEvent ();
439
return target.PointingDeviceType;
443
public uint SystemTabletID {
445
CheckTabletProximityEvent ();
446
return target.SystemTabletID;
450
public uint TabletID {
452
CheckTabletProximityEvent ();
453
return target.TabletID;
457
public long UniqueID {
459
CheckTabletProximityEvent ();
460
return target.UniqueID;
464
public uint VendorID {
466
CheckTabletProximityEvent ();
467
return target.VendorID;
471
public uint VendorPointingDeviceType {
473
CheckTabletProximityEvent ();
474
return target.VendorPointingDeviceType;
480
#region Touch and Gesture Events
482
bool IsTouchOrGestureEvent ()
488
void CheckTouchOrGestureEvent ()
490
if (IsTouchOrGestureEvent ())
492
throw new InvalidOperationException ("Not a touch or gesture event.");
495
internal float Magnification {
497
CheckTouchOrGestureEvent ();
498
return target.Magnification;
504
#region Scroll Wheel and Flick Events
506
bool IsScrollWheelOrFlickEvent ()
508
if (IsScrollWheelEvent ())
513
void CheckScrollWheelOrFlickEvent ()
515
if (IsScrollWheelOrFlickEvent ())
517
throw new InvalidOperationException ("Not a scroll wheel or flick event.");
520
public bool HasPreciseScrollingDeltas {
522
CheckScrollWheelOrFlickEvent ();
523
return target.HasPreciseScrollingDeltas;
527
public float ScrollingDeltaX {
529
CheckScrollWheelOrFlickEvent ();
530
return target.ScrollingDeltaX;
534
public float ScrollingDeltaY {
536
CheckScrollWheelOrFlickEvent ();
537
return target.ScrollingDeltaY;
541
public NSEventPhase MomentumPhase {
543
CheckScrollWheelOrFlickEvent ();
544
return target.MomentumPhase;
548
public NSEventPhase Phase {
550
CheckScrollWheelOrFlickEvent ();
555
public bool IsDirectionInvertedFromDevice {
557
CheckScrollWheelOrFlickEvent ();
558
return target.IsDirectionInvertedFromDevice;