public virtual void ProcessEvents(Event e) { if (e.isKey) { OnKeyDown(this, e); return; } if (!viewRect.Contains(e.mousePosition)) { return; } switch (e.button) { case 0: switch (e.type) { case EventType.MouseDown: OnLeftMouseDown?.Invoke(this, e); break; case EventType.MouseDrag: OnLeftMouseDrag?.Invoke(this, e); break; case EventType.MouseUp: OnLeftMouseUp?.Invoke(this, e); break; } break; case 1: switch (e.type) { case EventType.MouseDown: OnRightMouseDown?.Invoke(this, e); break; case EventType.MouseDrag: OnRightMouseDrag?.Invoke(this, e); break; case EventType.MouseUp: OnRightMouseUp?.Invoke(this, e); break; } break; } }
private void CheckClickUp() { if (Input.GetMouseButtonUp(0)) { mouseLeftUpPos = Input.mousePosition; OnLeftMouseUp?.Invoke(); dragMode = DragMode.NoDrag; } if (Input.GetMouseButtonUp(1)) { mouseRightUpPos = Input.mousePosition; OnRightMouseUp?.Invoke(); dragMode = DragMode.NoDrag; inputMode = InputMode.SelectMode; } }
/// <summary>Register background right mouse up event handler.</summary> /// <param name="callback">callback function </param> public static void ObserveRightMouseUp(OnRightMouseUp callback) { RemoveOnRightMouseUp(); _rightMouseUpGcHandle = GCHandle.Alloc(callback, GCHandleType.Normal); onRightMouseUp((IntPtr)_rightMouseUpGcHandle.Value, OnRightMouseUpFromNative); }