private static void EditorGlobalKeyPress() { //here basic key event (can be keyDown, up, held...) OnGlobalKeyEvent?.Invoke(Event.current); if (EditorWindow.mouseOverWindow != null && EditorWindow.mouseOverWindow.GetType() == typeof(SceneView)) { OnGlobalKeyEventOverSceneView?.Invoke(Event.current, (SceneView)EditorWindow.mouseOverWindow); } //fire special event on key up if (Event.current.type == EventType.KeyUp) { _clickCount++; if (_timerDoubleClick.IsRunning() && _lastKeyCode == Event.current.keyCode) { //2 key press if (_clickCount == 2) { OnGlobalKeyPressUpDoubleClick?.Invoke(Event.current); if (EditorWindow.mouseOverWindow != null && EditorWindow.mouseOverWindow.GetType() == typeof(SceneView)) { OnGlobalKeyPressUpDoubleClickOverSceneView?.Invoke(Event.current, (SceneView)EditorWindow.mouseOverWindow); } } } else { //first key press _clickCount = 1; OnGlobalKeyUp?.Invoke(Event.current); if (EditorWindow.mouseOverWindow != null && EditorWindow.mouseOverWindow.GetType() == typeof(SceneView)) { OnGlobalKeyPressUpOverSceneView?.Invoke(Event.current, (SceneView)EditorWindow.mouseOverWindow); } } //N click OnGlobalNKeyPressUp?.Invoke(Event.current, _clickCount); if (EditorWindow.mouseOverWindow != null && EditorWindow.mouseOverWindow.GetType() == typeof(SceneView)) { OnGlobalNKeyPressUpOverSceneView?.Invoke(Event.current, (SceneView)EditorWindow.mouseOverWindow, _clickCount); } _timerDoubleClick.StartChrono(_timingDoubleClick); _lastKeyCode = Event.current.keyCode; } }
private void ProcFunction() { while (true) { try { var starttime = DateTime.Now; //Get values point = Owner.GetMCursorPositionConsole(); pointg = Owner.GetMCursorPositionScreen(); mb = Owner.GetMouseButtonScreen(); mbg = Owner.GetMouseButtonScreen(); s = Owner.GetWindowSize(); for (var i = 0; i < 255; i++) { keysg[i] = Owner.GetKeyState(i); } //OnResize if (s.Width != olds.Width || s.Height != olds.Height) { OnResize?.Invoke(s); } //OnMouseMove //if (point.X != oldpoint.X || point.Y != oldpoint.Y) // OnMouseMove?.Invoke(point.X, point.Y, pointg.X, pointg.Y, mb); //OnGlobalMouseMove //if (pointg.X != oldpointg.X || pointg.Y != oldpointg.Y) // OnGlobalMouseMove?.Invoke(pointg.X, pointg.Y, mbg); //OnGlobalKey* for (var i = 0; i < 255; i++) { if (keysg[i] != oldkeysg[i]) { if (keysg[i] == 0) { OnGlobalKeyUp?.Invoke(i, keysg); } else { OnGlobalKeyDown?.Invoke(i, keysg); } break; } } //OnMouse* //if (mb != oldmb) // if (mb == MButton.Null) // OnMouseUp?.Invoke(point.X, point.Y, pointg.X, pointg.Y, point.X != new Point().X && point.Y != new Point().Y, oldmb); // else if (mb != MButton.Null) // OnMouseDown?.Invoke(point.X, point.Y, pointg.X, pointg.Y, point.X != new Point().X && point.Y != new Point().Y, mb); //OnKeyDown if (Console.KeyAvailable) { key = Console.ReadKey().KeyChar; OnKeyDown?.Invoke(key); } //Save old values olds = s; keysg.CopyTo(oldkeysg, 0); oldkey = key; oldmb = mb; oldpoint = point; oldpointg = pointg; //OnEventHandlerTimerElapsed OnEventHandlerTimerElapsed?.Invoke((DateTime.Now - starttime).TotalMilliseconds); } catch (Exception ex) { CallException(ex); } Thread.Sleep(CyclicCheckingEventsInterval); } }