public static KeyEventArgs ToEtoKeyEventArgs(this NSEvent theEvent) { char keyChar = !string.IsNullOrEmpty(theEvent.Characters) ? theEvent.Characters[0] : '\0'; Keys key = KeyMap.MapKey(theEvent.KeyCode); KeyEventArgs kpea; Keys modifiers = KeyMap.GetModifiers(theEvent); key |= modifiers; if (key != Keys.None) { if (((modifiers & ~(Keys.Shift | Keys.Alt)) == 0)) { kpea = new KeyEventArgs(key, KeyEventType.KeyDown, keyChar); } else { kpea = new KeyEventArgs(key, KeyEventType.KeyDown); } } else { kpea = new KeyEventArgs(key, KeyEventType.KeyDown, keyChar); } return(kpea); }
public static KeyEventArgs ToEtoKeyEventArgs(this NSEvent theEvent) { char keyChar = !string.IsNullOrEmpty(theEvent.Characters) ? theEvent.Characters[0] : '\0'; Keys key = KeyMap.MapKey(theEvent.KeyCode, theEvent.ModifierFlags); KeyEventArgs kpea; Keys modifiers = theEvent.ModifierFlags.ToEto(); key |= modifiers; KeyEventType keyEventType = theEvent.Type == NSEventType.KeyUp ? KeyEventType.KeyUp : KeyEventType.KeyDown; if (key != Keys.None) { if (((modifiers & ~(Keys.Shift | Keys.Alt)) == 0)) { kpea = new KeyEventArgs(key, keyEventType, keyChar); } else { kpea = new KeyEventArgs(key, keyEventType); } } else { kpea = new KeyEventArgs(key, keyEventType, keyChar); } return(kpea); }
public static MouseEventArgs GetMouseEvent(NSView view, NSEvent theEvent, bool includeWheel) { var pt = Conversions.GetLocation(view, theEvent); Keys modifiers = KeyMap.GetModifiers(theEvent); MouseButtons buttons = theEvent.GetMouseButtons(); SizeF? delta = null; if (includeWheel) { delta = new SizeF((float)theEvent.DeltaX, (float)theEvent.DeltaY); } return(new MouseEventArgs(buttons, modifiers, pt, delta)); }