public override void AttachEvent(string handler) { switch (handler) { case Eto.Forms.Control.MouseEnterEvent: HandleEvent(Eto.Forms.Control.MouseLeaveEvent); break; case Eto.Forms.Control.MouseLeaveEvent: mouseOptions |= NSTrackingAreaOptions.MouseEnteredAndExited; mouseMove = true; HandleEvent(Eto.Forms.Control.SizeChangedEvent); CreateTracking(); break; case Eto.Forms.Control.MouseMoveEvent: mouseOptions |= NSTrackingAreaOptions.MouseMoved; mouseMove = true; HandleEvent(Eto.Forms.Control.SizeChangedEvent); CreateTracking(); AddMethod(selMouseDragged, new Action <IntPtr, IntPtr, IntPtr> (TriggerMouseDragged), "v@:@"); AddMethod(selRightMouseDragged, new Action <IntPtr, IntPtr, IntPtr> (TriggerMouseDragged), "v@:@"); break; case Eto.Forms.Control.SizeChangedEvent: Control.PostsFrameChangedNotifications = true; this.AddObserver(NSView.NSViewFrameDidChangeNotification, delegate(ObserverActionArgs e) { var h = ((MacView <T, W>)(e.Widget.Handler)); var oldFrameSize = h.oldFrameSize; h.OnSizeChanged(EventArgs.Empty); var newSize = e.Widget.Size; if (oldFrameSize == null || oldFrameSize.Value != newSize) { e.Widget.OnSizeChanged(EventArgs.Empty); h.oldFrameSize = newSize; } }); break; case Eto.Forms.Control.MouseDownEvent: AddMethod(selMouseDown, new Action <IntPtr, IntPtr, IntPtr> (TriggerMouseDown), "v@:@"); AddMethod(selRightMouseDown, new Action <IntPtr, IntPtr, IntPtr> (TriggerMouseDown), "v@:@"); break; case Eto.Forms.Control.MouseUpEvent: AddMethod(selMouseUp, new Action <IntPtr, IntPtr, IntPtr> (TriggerMouseUp), "v@:@"); AddMethod(selRightMouseUp, new Action <IntPtr, IntPtr, IntPtr> (TriggerMouseUp), "v@:@"); break; case Eto.Forms.Control.MouseDoubleClickEvent: HandleEvent(Eto.Forms.Control.MouseDownEvent); break; case Eto.Forms.Control.KeyDownEvent: AddMethod(selKeyDown, new Action <IntPtr, IntPtr, IntPtr> (TriggerKeyDown), "v@:@"); break; case Eto.Forms.Control.LostFocusEvent: AddMethod(selResignFirstResponder, new Func <IntPtr, IntPtr, bool> (TriggerLostFocus), "B@:"); break; case Eto.Forms.Control.GotFocusEvent: AddMethod(selBecomeFirstResponder, new Func <IntPtr, IntPtr, bool> (TriggerGotFocus), "B@:"); break; case Eto.Forms.Control.ShownEvent: case Eto.Forms.Control.HiddenEvent: // TODO break; default: base.AttachEvent(handler); break; } }
public override void AttachEvent(string id) { switch (id) { case Eto.Forms.Control.MouseEnterEvent: HandleEvent(Eto.Forms.Control.MouseLeaveEvent); break; case Eto.Forms.Control.MouseLeaveEvent: mouseOptions |= NSTrackingAreaOptions.MouseEnteredAndExited; mouseMove = true; HandleEvent(Eto.Forms.Control.SizeChangedEvent); CreateTracking(); break; case Eto.Forms.Control.MouseMoveEvent: mouseOptions |= NSTrackingAreaOptions.MouseMoved; mouseMove = true; HandleEvent(Eto.Forms.Control.SizeChangedEvent); CreateTracking(); AddMethod(selMouseDragged, new Action <IntPtr, IntPtr, IntPtr>(TriggerMouseDragged), "v@:@"); AddMethod(selRightMouseDragged, new Action <IntPtr, IntPtr, IntPtr>(TriggerMouseDragged), "v@:@"); break; case Eto.Forms.Control.SizeChangedEvent: AddMethod(selSetFrameSize, new Action <IntPtr, IntPtr, CGSize>(SetFrameSizeAction), "v@:{CGSize=ff}", ContainerControl); break; case Eto.Forms.Control.MouseDownEvent: AddMethod(selMouseDown, new Action <IntPtr, IntPtr, IntPtr>(TriggerMouseDown), "v@:@"); AddMethod(selRightMouseDown, new Action <IntPtr, IntPtr, IntPtr>(TriggerMouseDown), "v@:@"); break; case Eto.Forms.Control.MouseUpEvent: AddMethod(selMouseUp, new Action <IntPtr, IntPtr, IntPtr>(TriggerMouseUp), "v@:@"); AddMethod(selRightMouseUp, new Action <IntPtr, IntPtr, IntPtr>(TriggerMouseUp), "v@:@"); break; case Eto.Forms.Control.MouseDoubleClickEvent: HandleEvent(Eto.Forms.Control.MouseDownEvent); break; case Eto.Forms.Control.MouseWheelEvent: AddMethod(selScrollWheel, new Action <IntPtr, IntPtr, IntPtr>(TriggerMouseWheel), "v@:@"); break; case Eto.Forms.Control.KeyDownEvent: AddMethod(selKeyDown, new Action <IntPtr, IntPtr, IntPtr>(TriggerKeyDown), "v@:@"); break; case Eto.Forms.Control.KeyUpEvent: AddMethod(selKeyUp, new Action <IntPtr, IntPtr, IntPtr>(TriggerKeyUp), "v@:@"); break; case Eto.Forms.Control.LostFocusEvent: AddMethod(selResignFirstResponder, new Func <IntPtr, IntPtr, bool>(TriggerLostFocus), "B@:"); break; case Eto.Forms.Control.GotFocusEvent: AddMethod(selBecomeFirstResponder, new Func <IntPtr, IntPtr, bool>(TriggerGotFocus), "B@:"); break; case Eto.Forms.Control.ShownEvent: // TODO break; case Eto.Forms.Control.TextInputEvent: AddMethod(selInsertText, new Action <IntPtr, IntPtr, IntPtr>(TriggerTextInput), "v@:@"); break; default: base.AttachEvent(id); break; } }
protected DragEventTrapView() { const NSTrackingAreaOptions options = NSTrackingAreaOptions.ActiveInKeyWindow | NSTrackingAreaOptions.InVisibleRect | NSTrackingAreaOptions.MouseEnteredAndExited; var trackingArea = new NSTrackingArea(default, options, this, null);