public Window(WindowConfig config) { _config = config; var opts = WindowOptions.DefaultVulkan; opts.WindowBorder = WindowBorder.Resizable; opts.Size = new Silk.NET.Maths.Vector2D <int>((int)config.Width, (int)config.Height); opts.Title = config.Title; opts.WindowState = config.Fullscreen ? WindowState.Fullscreen : WindowState.Normal; _window = Silk.NET.Windowing.Window.Create(opts); _window.Render += (time) => DrawFrame?.Invoke(time); _window.Initialize(); _input = _window.CreateInput(); var primaryKeyboard = _input.Keyboards.FirstOrDefault(); if (primaryKeyboard != null) { primaryKeyboard.KeyDown += (keyboard, key, code) => OnKeyDown?.Invoke(key); primaryKeyboard.KeyUp += (keyboard, key, code) => OnKeyUp?.Invoke(key); } for (int i = 0; i < _input.Mice.Count; i++) { _input.Mice[i].Cursor.CursorMode = config.CursorDisabled ? CursorMode.Disabled : CursorMode.Normal; _input.Mice[i].MouseMove += (mouse, pos) => OnCursorPosition?.Invoke(pos.X, pos.Y); _input.Mice[i].Scroll += (mouse, wheel) => OnScroll?.Invoke(wheel.X, wheel.Y); _input.Mice[i].MouseDown += (mouse, button) => OnMouseDown?.Invoke(button); _input.Mice[i].MouseUp += (mouse, button) => OnMouseUp?.Invoke(button); } }
IntPtr HookProcFunction(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode == 0) { MSLLHOOKSTRUCT mhs = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); var inwindow = Owner.MouseInWindow(mhs.pt.X, mhs.pt.Y); switch ((WM)wParam.ToInt32()) { case WM.MOUSEMOVE: if (inwindow) { OnMouseMove?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, Owner.GetMouseButtonConsole()); } OnGlobalMouseMove?.Invoke(mhs.pt.X, mhs.pt.Y, Owner.GetMouseButtonScreen()); break; case WM.LBUTTONDOWN: OnMouseDown?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Left); break; case WM.MBUTTONDOWN: OnMouseDown?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Center); break; case WM.RBUTTONDOWN: OnMouseDown?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Right); break; case WM.XBUTTONDOWN: OnMouseDown?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.XBUTTON1 | MButton.XBUTTON2); break; case WM.LBUTTONUP: OnMouseUp?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Left); break; case WM.MBUTTONUP: OnMouseUp?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Center); break; case WM.RBUTTONUP: OnMouseUp?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.Right); break; case WM.XBUTTONUP: OnMouseUp?.Invoke(Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).X, Owner.ToConsoleCoord(mhs.pt.X, mhs.pt.Y).Y, mhs.pt.X, mhs.pt.Y, inwindow, MButton.XBUTTON1 | MButton.XBUTTON2); break; case WM.MOUSEWHEEL: OnMouseWheel?.Invoke(GetWheelStateByData(mhs.mouseData), mhs.mouseData, mhs.pt.X, mhs.pt.Y, Owner.GetMouseButtonScreen()); break; default: break; } } return(WinApi.CallNextHookEx(hHook, nCode, wParam, lParam)); }
public void MouseUp(int screenX, int screenY, MouseButton button) { mouseX = screenX; mouseY = screenY; mouseButtons &= ~button; OnMouseUp?.Invoke(this, CreateMouseEventArgs(screenX, screenY, button)); }
private void RaiseOnMouseUp(InputEventArgs e) { if (OnMouseUp == null) { return; } try { if (Element == null) { Element = AutomationHelper.GetFromPoint(e.X, e.Y); } } catch (Exception) { } try { e.Element = Element; if (e.Element != null) { e.Element.Refresh(); } // if (e.Element != null && e.Element.ProcessId == currentprocessid) return; OnMouseUp?.Invoke(e); } catch (Exception ex) { Log.Error(ex.ToString()); } }
static public void InvokeOnMouseUp(OpenTK.Input.MouseButtonEventArgs e) { if (OnMouseUp != null) { OnMouseUp.Invoke(null, e); } }
// Update Method public override void Update(GameTime gameTime) { previousMouse = currentMouse; // Current and previous state currentMouse = Mouse.GetState(); // functions to recieve only one mouse click at a time Rectangle mouseRectangle = new Rectangle(currentMouse.X, currentMouse.Y, 1, 1); // Rectangle of the mouse isHovering = false; if (mouseRectangle.Intersects(Rectangle)) { isHovering = true; if (currentMouse.LeftButton == ButtonState.Pressed) // Conditions for the mouse being down { OnMouseDown?.Invoke(this, new EventArgs()); } if (currentMouse.LeftButton == ButtonState.Released && previousMouse.LeftButton == ButtonState.Pressed) // Conditions for the mouse being clicked { Click?.Invoke(this, new EventArgs()); } } if (currentMouse.LeftButton == ButtonState.Released) // Conditions for the mouse being released { OnMouseUp?.Invoke(this, new EventArgs()); } }
internal virtual void DoMouseUp(MouseButton button) { if (MouseEnabled) { OnMouseUp?.Invoke(button); } }
private void Poll() { while (true) { VREvent_t evt = new VREvent_t(); var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t)); if (!OpenVR.Overlay.PollNextOverlayEvent(overlayHandle, ref evt, size)) { Thread.Sleep(PollingRate); continue; } ; switch ((EVREventType)evt.eventType) { case EVREventType.VREvent_MouseMove: OnMouseMove?.Invoke(this, evt); break; case EVREventType.VREvent_MouseButtonDown: OnMouseDown?.Invoke(this, evt); break; case EVREventType.VREvent_MouseButtonUp: OnMouseUp?.Invoke(this, evt); break; } } }
public static void ProcessMouseEvent(SDL_Event ev) { switch (ev.type) { case SDL_EventType.SDL_MOUSEBUTTONDOWN: SetMouseButtonState(ev.button.button, true); if (OnMouseDown != null) { var button = TranslatePlatformMouseButton(ev.button.button); OnMouseDown.Invoke(button); } break; case SDL_EventType.SDL_MOUSEBUTTONUP: SetMouseButtonState(ev.button.button, false); if (OnMouseUp != null) { var button = TranslatePlatformMouseButton(ev.button.button); OnMouseUp.Invoke(button); } break; case SDL_EventType.SDL_MOUSEMOTION: OnMouseMove?.Invoke(); break; } }
public static void GUIEvents() { var current = Event.current; switch (current.type) { case EventType.MouseDown: if (mouseDownEvent != null) { mouseDownEvent.Invoke(); } break; case EventType.MouseDrag: if (mouseDragEvent != null) { mouseDragEvent.Invoke(); } break; case EventType.MouseUp: if (mouseUpEvent != null) { mouseUpEvent.Invoke(); } break; } }
private void Update() { if (Input.GetMouseButtonDown(0) && Input.mousePosition.x > 150) { for (int i = lines.Count - 1; i >= 0; i--) { Destroy(lines[i].gameObject); lines.RemoveAt(i); } GameObject lineGO = Instantiate(linePrefab); activeLine = lineGO.GetComponent <Line>(); lines.Add(activeLine); } if (Input.GetMouseButtonUp(0) && activeLine != null) { OnMouseUp?.Invoke(activeLine); activeLine = null; } if (activeLine != null) { if (Input.mousePosition.x > 150) { Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); activeLine.UpdateLine(mousePos); } } }
private IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam) { if ((int)wParam == WM_MOUSEMOVE) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseMove?.Invoke(e)); } else if ((int)wParam == WM_LBUTTONDOWN || (int)wParam == WM_RBUTTONDOWN) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseDown?.Invoke(e)); } else if ((int)wParam == WM_LBUTTONUP || (int)wParam == WM_RBUTTONUP) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseUp?.Invoke(e)); } return(CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam)); }
private void MouseUp() { firstMouseClick = true; OnMouseUp?.Invoke(); endPress = Input.mousePosition; AudioSource.PlayClipAtPoint(jumpSnd, transform.position); AddForce(); }
// 鼠标左键在窗口内放开 public virtual void onMouseUp(Vector3 mousePos) { mPressCallback?.Invoke(this, false); if (lengthLess(mMouseDownPosition - mousePos, FrameDefine.CLICK_THRESHOLD)) { mClickCallback?.Invoke(this); } mOnMouseUp?.Invoke(mousePos); }
public override void MouseUp(UIMouseEvent evt) { if (_isDragging) { _isDragging = false; OnValueChange?.Invoke(Value, this); } OnMouseUp?.Invoke(evt, this); }
public virtual void MouseLeftUp(UIMouseEvent e) { // Main.NewText("抬起"); MouseDownedLeft = false; OnMouseUp?.Invoke(e, this); if (PropagationRule.HasFlag(PropagationFlags.MouseLeftUp)) { Parent?.MouseLeftUp(e); } }
private void OnMouse(object sender, ButtonValueChangedArgs bvca) { if (bvca.Pressed) { OnMouseDown?.Invoke(this); } else { OnMouseUp?.Invoke(this); } }
internal void MouseOver(RaycastHit hitInfo) { if (Input.GetMouseButtonDown(Left)) { Debug.Log("On Mouse Down"); mouseDownWatchers?.Invoke(hitInfo); Debug.Log("On Mouse Down watchers called."); } if (Input.GetMouseButtonUp(Left)) { mouseUpWatchers?.Invoke(hitInfo); } }
void MarkMouseButtonAsPressed(MSLLHOOKSTRUCT hookStruct, MouseEventArgs.Buttons button, bool pressed) { if (pressed && !_currentlyPressed.Contains((int)button)) { _currentlyPressed.Add((int)button); OnMouseDown?.Invoke(this, new MouseEventArgs(button, hookStruct.pt.x, hookStruct.pt.y)); } else if (!pressed && _currentlyPressed.Contains((int)button)) { _currentlyPressed.Remove((int)button); OnMouseUp?.Invoke(this, new MouseEventArgs(button, hookStruct.pt.x, hookStruct.pt.y)); } }
private static void InputEventHandler(InputEventArgs e) { switch (e.Type) { case InputEventType.KeyUp: OnKeyUp.Invoke(e); break; case InputEventType.KeyDown: OnKeyDown.Invoke(e); break; case InputEventType.MouseUp: OnMouseUp.Invoke(e); break; case InputEventType.MouseDown: OnMouseDown.Invoke(e); break; case InputEventType.MouseMove: OnMouseMove.Invoke(e); break; } }
public void Update() { if (Input.GetMouseButtonDown(0)) { OnMouseDwn?.Invoke(); isPressed = true; } if (Input.GetMouseButtonUp(0)) { OnMouseUp?.Invoke(); isPressed = false; } if (isPressed) { OnMouseDrg?.Invoke(); } }
internal override void GHook_MouseUp(object sender, MouseEventArgs e) { if (!Loaded) { return; } var mx = e.X - Window.X; var my = e.Y - Window.Y; //if (ScaleMode == DrawingAreaScaleMode.ScaleAll) //{ // mx = (int)(mx / Scale.X); // my = (int)(my / Scale.Y); //} DxWindow.OnMouseUp(DxWindow, DxWindow, e, new SharpDX.Point(mx, my)); OnMouseUp?.Invoke(sender, e); }
private bool HasMouseButtonInput(int button) { if (Input.GetMouseButtonDown(button)) { OnMouseDown?.Invoke(button, Input.mousePosition); return(true); } else if (Input.GetMouseButton(button)) { OnMouseDrag?.Invoke(button, Input.mousePosition, Input.GetAxis(MouseXAxis), Input.GetAxis(MouseYAxis)); return(true); } else if (Input.GetMouseButtonUp(button)) { OnMouseUp?.Invoke(button, Input.mousePosition); return(true); } return(false); }
public virtual void MouseUp(MouseButton button, Vec2 position) { foreach (var child in children) { if (child.Inside(position) || mouseFocus == child) { child.MouseUp(button, position); } } mouseFocus = null; if (Pressed) { Release(); if (Inside(position)) { Click(); } } Pressed = false; OnMouseUp?.Invoke(button, position); }
private void MouseUp(int buttonId, Vector3 mousePosition) { if (!canInputBeMade) { return; } if (!BuilderInWorldUtils.IsPointerOverUIElement() && !BuilderInWorldUtils.IsPointerOverMaskElement(layerToStopClick)) { OnMouseUp?.Invoke(buttonId, mousePosition); if (Vector3.Distance(mousePosition, lastMousePosition) >= movementClickThreshold) { return; } if (Time.unscaledTime >= lastTimeMouseDown + msClickThreshold / 1000) { return; } OnMouseClick?.Invoke(buttonId, mousePosition); } }
private IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam) { try { if ((int)wParam == WM_MOUSEMOVE) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseMove?.Invoke(e)); } else if ((int)wParam == WM_LBUTTONDOWN || (int)wParam == WM_RBUTTONDOWN) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseDown?.Invoke(e)); } else if ((int)wParam == WM_LBUTTONUP || (int)wParam == WM_RBUTTONUP) { var e = new InputEventArgs(); var pt = new POINT(); GetPhysicalCursorPos(ref pt); e.X = pt.x; e.Y = pt.y; Task.Run(() => OnMouseUp?.Invoke(e)); } return(CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam)); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("LowLevelMouseProc: " + ex.Message); return(IntPtr.Zero); } }
// Update is called once per frame void Update() { //We transform the touch position into word space from screen space and store it. Vector3 touchPosWorld = MainCamera.ScreenToWorldPoint(Input.mousePosition); Vector2 touchPosWorld2D = new Vector2(touchPosWorld.x, touchPosWorld.y); Transform hitTransform = null; //We now raycast with this information. If we have hit something we can process it. RaycastHit2D hitInformation = Physics2D.Raycast(touchPosWorld2D, MainCamera.transform.forward); if (Physics.Raycast(touchPosWorld, Vector3.forward, out var hitInformation3D)) { hitTransform = hitInformation3D.transform; } else if (hitInformation.transform) { hitTransform = hitInformation.transform; } if (Input.GetMouseButtonDown(0)) { OnMouseDown?.Invoke(touchPosWorld2D, hitTransform); } if (Input.GetMouseButton(0)) { OnMouseMove?.Invoke(touchPosWorld2D, hitTransform); } if (Input.GetMouseButtonUp(0)) { OnMouseUp?.Invoke(touchPosWorld2D, hitTransform); } if (Input.GetKeyDown(KeyCode.Space)) { LevelManager.LoadLevel(0); } }
private void MouseUp(int buttonId, Vector3 mousePosition) { if (!isEditModeActive) { return; } if (currentClickIsOnUi) { OnMouseClickOnUI?.Invoke(buttonId, mousePosition); currentClickIsOnUi = false; return; } if (!canInputBeMade) { return; } if (!BIWUtils.IsPointerOverUIElement()) { OnMouseUp?.Invoke(buttonId, mousePosition); if (Vector3.Distance(mousePosition, lastMousePosition) >= MOVEMENT_CLICK_THRESHOLD) { return; } if (Time.unscaledTime >= lastTimeMouseDown + MS_CLICK_THRESHOLD / 1000) { return; } OnMouseClick?.Invoke(buttonId, mousePosition); } else { OnMouseUpOnUI?.Invoke(buttonId, mousePosition); } }
// 鼠标左键在窗口内放开 public virtual void onMouseUp(Vector3 mousePos) { mPressing = false; mPressedTime = -1.0f; mPressCallback?.Invoke(this, false); if (lengthLess(mMouseDownPosition - mousePos, CommonDefine.CLICK_THRESHOLD)) { mObjectPreClickCallback?.Invoke(this, mObjectPreClickCallbackUserData); mClickCallback?.Invoke(this); if (mDoubleClickCallback != null && mLastClickTime > 0.0f && mLastClickTime < CommonDefine.DOUBLE_CLICK_THRESHOLD) { mDoubleClickCallback(this); // 已完成双击操作,结束计时 mLastClickTime = -1.0f; } // 未开始双击计时则开始计时 if (mLastClickTime < 0.0f) { mLastClickTime = 0.0f; } } mOnMouseUp?.Invoke(mousePos); mOnLongPressing?.Invoke(0.0f); }
internal void DispatchEvent(Map map, HtmlMarkerJsEventArgs eventArgs) { if (eventArgs.Options != null) { var popupOptions = Options.Popup; Options = eventArgs.Options; Options.Popup = popupOptions; } switch (eventArgs.Type) { case "click": OnClick?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "contextmenu": OnContextMenu?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "dblclick": OnDblClick?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "drag": OnDrag?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "dragend": OnDragEnd?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "dragstart": OnDragStart?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "keydown": OnKeyDown?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "keypress": OnKeyPress?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "keyup": OnKeyUp?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "mousedown": OnMouseDown?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "mouseenter": OnMouseEnter?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "mouseleave": OnMouseLeave?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "mousemove": OnMouseMove?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "mouseout": OnMouseOut?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "mouseover": OnMouseOver?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; case "mouseup": OnMouseUp?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this)); break; } }