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; } }
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()); } }
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); } }
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 override void resetProperty() { base.resetProperty(); // 重置所有成员变量 mObjectID = -1; mPhysicsAcceleration = Vector3.zero; mLastPhysicsSpeed = Vector3.zero; mPhysicsSpeed = Vector3.zero; mLastPhysicsPosition = Vector3.zero; mCurFramePosition = Vector3.zero; mLastPosition = Vector3.zero; mMouseDownPosition = Vector3.zero; mLastSpeed = Vector3.zero; mMoveSpeed = Vector3.zero; mObject = null; mTransform = null; mAudioSource = null; mOnMouseEnter = null; mOnMouseLeave = null; mOnMouseDown = null; mOnMouseUp = null; mOnMouseMove = null; mClickCallback = null; mHoverCallback = null; mPressCallback = null; mMovedDuringFrame = false; mHasLastPosition = false; mDestroyObject = true; mDestroied = false; mMouseHovered = false; mHandleInput = true; mPassRay = false; }
static public void InvokeOnMouseUp(OpenTK.Input.MouseButtonEventArgs e) { if (OnMouseUp != null) { OnMouseUp.Invoke(null, e); } }
internal virtual void DoMouseUp(MouseButton button) { if (MouseEnabled) { OnMouseUp?.Invoke(button); } }
// 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()); } }
public void MouseUp(int screenX, int screenY, MouseButton button) { mouseX = screenX; mouseY = screenY; mouseButtons &= ~button; OnMouseUp?.Invoke(this, CreateMouseEventArgs(screenX, screenY, 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)); }
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 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 void MouseUp() { firstMouseClick = true; OnMouseUp?.Invoke(); endPress = Input.mousePosition; AudioSource.PlayClipAtPoint(jumpSnd, transform.position); AddForce(); }
protected async Task OnMouseUpAsync(MouseEventArgs args) { await ChangeValue(); if (OnMouseUp.HasDelegate) { await OnMouseUp.InvokeAsync(args); } }
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); } }
public AnnotationHelper( OnAnnotationChanged onAnnotationChangedCallback = null, OnPageChanged onPageChangedCallback = null, OnMouseDown onMouseDownCallback = null, OnMouseUp onMouseUpCallback = null) { OnAnnotationChangedCallback = onAnnotationChangedCallback ?? (async(W3CWebAnnotationModel[] annotations) => { }); OnPageChangedCallback = onPageChangedCallback ?? (async(int newPage) => { }); OnMouseDownCallback = onMouseDownCallback ?? (async(double viewportX, double viewportY) => { }); OnMouseUpCallback = onMouseUpCallback ?? (async(double viewportX, double viewportY) => { }); }
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); }
protected async Task OnMouseUpAsync(MouseEventArgs args) { if (!EqualityComparer <TValue> .Default.Equals(CurrentValue, _inputValue)) { if (!_compositionInputting) { CurrentValue = _inputValue; if (OnChange.HasDelegate) { await OnChange.InvokeAsync(Value); } } } if (OnMouseUp.HasDelegate) { await OnMouseUp.InvokeAsync(args); } }
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); }
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); } }
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 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); } }
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; } }