protected virtual void Up(int x, int y, int xglobal, int yglobal, bool inwindow, MButton mb) { if (PointOnControl(x, y) && inwindow) { MouseUp?.Invoke(x, y, mb); } }
private void HandleButtonEvent(MouseState state, MouseButton button, ButtonState prevState, ButtonState currentState) { if (prevState != currentState) { if (_clickCooldown > 0 && currentState == ButtonState.Released) { _clickCooldown = 0; if (_lastClick == button) { var ev = new MouseButtonEventArgs(state, button, currentState); MouseDoubleClick?.Invoke(this, ev); } } else { var ev = new MouseButtonEventArgs(state, button, currentState); if (currentState == ButtonState.Pressed) { MouseDown?.Invoke(this, ev); } else { MouseUp?.Invoke(this, ev); _lastClick = button; _clickCooldown = _clickCooldownStart; } } } }
private void Base_MouseUp(object sender, MouseEventArgs e) { if (canClick) { MouseUp?.Invoke(this, e); } }
public virtual bool OnMouseUp(DxWindow window, DxControl ctl, MouseEventArgs args, Point pt) { if (Childs != null) { for (var i = Childs.Count - 1; i >= 0; i--) { if (Childs[i].OnMouseUp(window, Childs[i], args, pt)) { return(true); } } } if (!IntersectTest(pt.X, pt.Y)) { return(false); } if (!IsMouseDown || !IsMouseOver) { return(false); } IsMouseDown = false; MouseUp?.Invoke(ctl, args, pt); return(true); }
private void CheckButtonReleased(Func <MouseState, ButtonState> getButtonState, MouseButton button) { if ((getButtonState(_currentState) == ButtonState.Released) && (getButtonState(_previousState) == ButtonState.Pressed)) { var args = new MouseEventArgs(ViewportAdapter, _gameTime.TotalGameTime, _previousState, _currentState, button); if (_mouseDownArgs.Button == args.Button) { var clickMovement = DistanceBetween(args.Position, _mouseDownArgs.Position); // If the mouse hasn't moved much between mouse down and mouse up if (clickMovement < DragThreshold) { if (!_hasDoubleClicked) { MouseClicked?.Invoke(this, args); } } else // If the mouse has moved between mouse down and mouse up { MouseDragEnd?.Invoke(this, args); _dragging = false; } } MouseUp?.Invoke(this, args); _hasDoubleClicked = false; _previousClickArgs = args; } }
public void Update(GameTime gt) { KeyboardState keyboardState = KeyboardState; Keys[] last = lastKeyboardState.GetPressedKeys(); Keys[] current = keyboardState.GetPressedKeys(); foreach (Keys key in current.Except(last)) { KeyDown?.Invoke(this, new KeyEventArgs(key, keyboardState)); } foreach (Keys key in last.Except(current)) { KeyUp?.Invoke(this, new KeyEventArgs(key, keyboardState)); } lastKeyboardState = KeyboardState; MouseState mouseState = MouseState; if (lastMouseState.LeftButton == ButtonState.Released && mouseState.LeftButton == ButtonState.Pressed) { MouseDown?.Invoke(this, new MouseEventArgs(MouseButtons.Left, mouseState)); } if (lastMouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton == ButtonState.Released) { MouseUp?.Invoke(this, new MouseEventArgs(MouseButtons.Left, mouseState)); } lastMouseState = mouseState; }
protected virtual void OnMouseUp(object sender, MouseButtonEventArgs e) { usingController.Value = false; if (e.Button == SFML.Window.Mouse.Button.Left) { Interlocked.Exchange(ref left, 0); } else if (e.Button == SFML.Window.Mouse.Button.Middle) { Interlocked.Exchange(ref middle, 0); } else if (e.Button == SFML.Window.Mouse.Button.Right) { Interlocked.Exchange(ref right, 0); } else if (e.Button == SFML.Window.Mouse.Button.XButton1) { Interlocked.Exchange(ref extra1, 0); } else if (e.Button == SFML.Window.Mouse.Button.XButton2) { Interlocked.Exchange(ref extra2, 0); } Interlocked.Exchange(ref currentWindow, (Display.Window)sender); MouseUp?.Invoke(sender, e); }
internal void OnMouseUp(MouseEventArgs args) { //foreach (var button in args.Buttons) var changed = new List <MouseButton>(); foreach (var button in args.Buttons) { if (MouseButtonStates[button] == ButtonState.Pressed) { MouseButtonStates[button] = ButtonState.Released; changed.Add(button); } } MouseUp?.Invoke(this, args); ChangeVisualState(); if (Click != null && changed.Contains(MouseButton.Left)) { OnClick(); args.Handled = true; } if (RightClick != null && changed.Contains(MouseButton.Right)) { OnRightClick(); args.Handled = true; } }
public void OnPointerUp(PointerEventData eventData) { if (MouseUp != null) { MouseUp.Invoke(this, eventData); } }
public override void Update(GameTime time, MouseState mouse, Vector2 position) { if (IsIn(position, mouse)) { if (previousState == ControlMS.None) { MouseEnter?.Invoke(this, mouse); State = ControlMS.Hot; } else if ((mouse.LeftButton == ButtonState.Pressed || mouse.RightButton == ButtonState.Pressed) && previousState != ControlMS.Pressed) { MouseDown?.Invoke(this, mouse); State = ControlMS.Pressed; } else if (mouse.LeftButton == ButtonState.Released && mouse.RightButton == ButtonState.Released && previousState == ControlMS.Pressed) { MouseUp?.Invoke(this, mouse); State = ControlMS.Hot; } } else { if (previousState != ControlMS.None) { MouseLeave?.Invoke(this, mouse); State = ControlMS.None; } } previousState = State; }
private void OnInternalMouseUp(object sender, OpenTK.Input.MouseButtonEventArgs e) { var args = new MouseButtonEventArgs(e); OnMouseUp(this, args); MouseUp?.Invoke(this, args); }
/// <summary> /// Receives all MouseUp events, and checks if control is focused and /// should receive event. /// </summary> /// <param name="args">Mouse event arguments.</param> protected virtual void MouseUpIntercept(MouseEventArgs args) { if (this.guiManager.GetFocus() == this) { MouseUp.Invoke(args); } }
private void onMouseUp(object sender, MouseButtonEventArgs e) { _controllers.CurrentlyUsingController = false; if (e.Button == SFML.Window.Mouse.Button.Left) { _mouse.LeftButtonDown = false; } else if (e.Button == SFML.Window.Mouse.Button.Middle) { _mouse.MiddleButtonDown = false; } else if (e.Button == SFML.Window.Mouse.Button.Right) { _mouse.RightButtonDown = false; } else if (e.Button == SFML.Window.Mouse.Button.XButton1) { _mouse.ExtraButton1Down = false; } else if (e.Button == SFML.Window.Mouse.Button.XButton2) { _mouse.ExtraButton2Down = false; } MouseUp?.Invoke(sender, e); }
public void OnMouseUp(MouseEventArgs e) { MouseUp?.Invoke(); if (ButtonType == Type.NOT_LOCKING) { switch (ButtonState) { case State.PRESSED_UP_DOWN: ButtonState = State.UP; break; case State.PRESSED_DOWN_UP: ButtonState = State.DOWN; break; } } else if (ButtonType == Type.LOCKING) { switch (ButtonState) { case State.PRESSED_UP_DOWN: ButtonState = State.DOWN; break; case State.PRESSED_DOWN_UP: ButtonState = State.DOWN; break; } } else if (ButtonType == Type.BISTABLE) { switch (ButtonState) { case State.PRESSED_UP_DOWN: ButtonState = State.DOWN; break; case State.PRESSED_DOWN_UP: ButtonState = State.UP; break; } } }
public DisplayPanelBox(PictureBox pBox, VScrollBar vs, HScrollBar hs) { pictureBox = pBox; pictureBox.MouseDown += (s, e) => { clicking = true; MouseDown.Invoke(e); }; pictureBox.MouseMove += (s, e) => { if (clicking) { MouseDrag.Invoke(e); } else { MouseMove.Invoke(e); } }; pictureBox.MouseUp += (s, e) => { clicking = false; MouseUp.Invoke(e); }; vScroll = vs; hScroll = hs; }
private void Viewport_MouseUp(Ray3 ray, MouseEventArgs e) { if (SurfaceMesh == null) { return; } List <Intersection> Intersections = new List <Intersection>(); Intersections.AddRange(SurfaceMesh.Intersect(ray)); foreach (var group in PointGroups) { if (group.IsVisible) { Intersections.AddRange(group.Intersect(ray)); } } if (Intersections.Count > 0) { Intersections.Sort((i1, i2) => i1.Distance.CompareTo(i2.Distance)); MouseUp?.Invoke(this, Intersections, e); } }
internal void OnMouseUp(MouseEventArgs e) { if (MouseUp != null) { MouseUp.Invoke(this, e); } }
/// <summary> /// Handles most events of the control /// </summary> /// <param name="eventName">Type of event to raise</param> /// <remarks></remarks> public void DoEvent(LightweightEvents eventName) { switch (eventName) { case LightweightEvents.Click: DoClick(); break; case LightweightEvents.MouseDown: if (canClick) { isPressed = true; Redraw(); } MouseDown?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; case LightweightEvents.MouseUp: if (canClick) { isPressed = false; Redraw(); } MouseUp?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; case LightweightEvents.MouseEnter: Scrolling = true; MouseEnter?.Invoke(this, new EventArgs()); break; case LightweightEvents.MouseLeave: Scrolling = false; MouseLeave?.Invoke(this, new EventArgs()); break; case LightweightEvents.Update: Update?.Invoke(this, null); break; case LightweightEvents.DoubleClick: DoubleClick?.Invoke(this, new EventArgs()); break; case LightweightEvents.MouseMove: MouseMove?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; default: throw new NotImplementedException("The requested event for this control does not exist"); } }
private void _mouseListener_MouseUp(object sender, MouseEventArgs e) { _scene?.FireMouseUp(e); MouseUp?.Invoke(sender, e); #if DEBUG Logger.Log("Mouse up."); #endif }
internal virtual void __Draw() { List <UnityEngine.GUILayoutOption> _Options = new List <UnityEngine.GUILayoutOption>(); if (MinWidth.HasValue) { _Options.Add(UnityEngine.GUILayout.MinWidth(MinWidth.Value)); } if (MaxWidth.HasValue) { _Options.Add(UnityEngine.GUILayout.MaxWidth(MaxWidth.Value)); } if (MinHeight.HasValue) { _Options.Add(UnityEngine.GUILayout.MinHeight(MinHeight.Value)); } if (MaxHeight.HasValue) { _Options.Add(UnityEngine.GUILayout.MaxHeight(MaxHeight.Value)); } this.Options = _Options.ToArray(); this.Draw(); try { if (UnityEngine.Event.current.type == UnityEngine.EventType.Repaint && !(this is IGroupItem)) { _ItemRect = UnityEngine.GUILayoutUtility.GetLastRect(); } if (_ItemRect.HasValue && UnityEngine.Event.current.isMouse) { if (UnityEngine.Event.current.type == UnityEngine.EventType.MouseDown) { if (_ItemRect.Value.Contains(UnityEngine.Event.current.mousePosition)) { MouseDown?.Invoke(this, UnityEngine.Event.current.button, UnityEngine.Event.current.mousePosition); } } else if (UnityEngine.Event.current.type == UnityEngine.EventType.MouseUp) { if (_ItemRect.Value.Contains(UnityEngine.Event.current.mousePosition)) { MouseUp?.Invoke(this, UnityEngine.Event.current.button, UnityEngine.Event.current.mousePosition); } } } } catch (Exception ex) { UnityEngine.Debug.Log("Unable to get rect of " + this.GetType().Name + ": " + ex.Message); } }
private void Update() { HandleMousePosition(Input.mousePosition); if (Input.GetMouseButtonDown(0)) { Cursor.visible = false; string animation = HandAnimations.MouseDown; switch (_anger) { case 2: animation = HandAnimations.MouseDownAngry; break; case 3: animation = HandAnimations.MouseDownHit; break; default: break; } _downAnger = _anger; _animator.SetTrigger(animation); } else if (Input.GetMouseButtonUp(0)) { string animation = HandAnimations.MouseUp; switch (_downAnger) { case 2: animation = HandAnimations.MouseUpAngry; break; case 3: animation = HandAnimations.MouseUpHit; break; default: break; } _animator.SetTrigger(animation); MouseUp?.Invoke(Input.mousePosition); } IsPressing = Input.GetMouseButton(0); //if (Input.GetKeyDown(KeyCode.Alpha1)) // Play(HandAnimations.Angry); //else if (Input.GetKeyDown(KeyCode.Alpha2)) // Play(HandAnimations.Ok); //else if (Input.GetKeyDown(KeyCode.Alpha3)) // Play(HandAnimations.ThumbUp); if (Input.GetKeyDown(KeyCode.UpArrow)) { AddAngry(); } }
/// <summary> /// check the MouseButton states. /// </summary> /// <param name="_b"></param> /// <param name="_state"></param> private void checkMouseButtons(MouseButtons _b, MouseState _state) { switch (_b) { case MouseButtons.Left: if (_state.LeftButton == ButtonState.Pressed) { if (!_left_pressed) { _left_pressed = true; var _cr = ThereIsConstants.AppSettings.WotoCreation; var _arg = new MouseEventArgs(_cr, _b); MouseDown?.Invoke(this, _arg); } } else { if (_left_pressed) { _left_pressed = false; var _cr = ThereIsConstants.AppSettings.WotoCreation; var _arg = new MouseEventArgs(_cr, _b); MouseUp?.Invoke(this, _arg); } } break; case MouseButtons.Right: if (_state.RightButton == ButtonState.Pressed) { if (!_right_pressed) { _right_pressed = true; var _cr = ThereIsConstants.AppSettings.WotoCreation; var _arg = new MouseEventArgs(_cr, _b); MouseDown?.Invoke(this, _arg); } } else { if (_right_pressed) { _right_pressed = false; var _cr = ThereIsConstants.AppSettings.WotoCreation; var _arg = new MouseEventArgs(_cr, _b); MouseUp?.Invoke(this, _arg); } } break; // ReSharper disable once RedundantEmptySwitchSection default: /* * TODO: in the future you have to add more options. */ return; } }
/// <summary> /// Hook process messages. /// </summary> /// <param name="nCode"></param> /// <param name="wParam"></param> /// <param name="lParam"></param> /// <returns></returns> static IntPtr HookProcFunction(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode == 0) { MSLLHOOKSTRUCT mhs = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); switch (wParam.ToInt32()) { case WM_LBUTTONDOWN: MouseDown?.Invoke(null, new MouseEventArgs(MouseButtons.Left, 1, mhs.pt.X, mhs.pt.Y, 0)); break; case WM_LBUTTONUP: MouseUp?.Invoke(null, new MouseEventArgs(MouseButtons.Left, 1, mhs.pt.X, mhs.pt.Y, 0)); break; case WM_MBUTTONDOWN: MouseDown?.Invoke(null, new MouseEventArgs(MouseButtons.Middle, 1, mhs.pt.X, mhs.pt.Y, 0)); break; case WM_MBUTTONUP: MouseUp?.Invoke(null, new MouseEventArgs(MouseButtons.Middle, 1, mhs.pt.X, mhs.pt.Y, 0)); break; case WM_MOUSEMOVE: MouseMove?.Invoke(null, new MouseEventArgs(MouseButtons.None, 1, mhs.pt.X, mhs.pt.Y, 0)); break; case WM_MOUSEWHEEL: if (!localHook) { MouseMove?.Invoke(null, new MouseEventArgs(MouseButtons.None, mhs.time, mhs.pt.X, mhs.pt.Y, mhs.mouseData >> 16)); } break; case WM_RBUTTONDOWN: MouseDown?.Invoke(null, new MouseEventArgs(MouseButtons.Right, 1, mhs.pt.X, mhs.pt.Y, 0)); break; case WM_RBUTTONUP: MouseUp?.Invoke(null, new MouseEventArgs(MouseButtons.Right, 1, mhs.pt.X, mhs.pt.Y, 0)); break; case WM_XBUTTONDOWN: MouseDown?.Invoke(null, new MouseEventArgs(API.HIWORD(mhs.mouseData) == 1 ? MouseButtons.XButton1 : MouseButtons.XButton2, 1, mhs.pt.X, mhs.pt.Y, 0)); break; case WM_XBUTTONUP: MouseUp?.Invoke(null, new MouseEventArgs(API.HIWORD(mhs.mouseData) == 1 ? MouseButtons.XButton1 : MouseButtons.XButton2, 1, mhs.pt.X, mhs.pt.Y, 0)); break; default: break; } } return(API.CallNextHookEx(hHook, nCode, wParam, lParam)); }
public virtual void PictureBox1_MouseUp(object sender, MouseEventArgs e) { isDrag = false; isMiddleDrag = false; var tt = BackTransform(e.X, e.Y); MouseUp?.Invoke(tt.X, tt.Y, e.Button); }
private void ButtonUpListener(object sender, MouseButtonEventArgs e) { var p = m_group.CursorPos; if (p.X > this.Position.X && p.X < this.Position.X + this.Size.Width && p.Y > this.Position.Y && p.Y < this.Position.Y + this.Size.Height) { MouseUp?.Invoke(this, e); } }
protected virtual void OnMouseUp(MouseButtonEventArgs args) { MouseUp?.Invoke(this, args); if (_mouseDown) { OnMouseClick(args); _mouseDown = false; } }
static MouseInputManager() { InputHooks.MouseMove += (o, e) => MouseMove?.Invoke(new MouseHookEventArgs(e.X, e.Y, (e.Button), e.Delta)); InputHooks.MouseClick += (o, e) => MouseClick?.Invoke(new MouseHookEventArgs(e.X, e.Y, (e.Button), e.Delta)); InputHooks.MouseDown += (o, e) => MouseDown?.Invoke(new MouseHookEventArgs(e.X, e.Y, (e.Button), e.Delta)); InputHooks.MouseUp += (o, e) => MouseUp?.Invoke(new MouseHookEventArgs(e.X, e.Y, (e.Button), e.Delta)); InputHooks.MouseWheel += (o, e) => MouseWheel?.Invoke(new MouseHookEventArgs(e.X, e.Y, (e.Button), e.Delta)); InputHooks.MouseDoubleClick += (o, e) => MouseDoubleClick?.Invoke(new MouseHookEventArgs(e.X, e.Y, (e.Button), e.Delta)); }
protected virtual void OnMouseUp(GLMouseEventArgs e) { //System.Diagnostics.Debug.WriteLine("up " + Name + " " + e.Location + " " + e.Button); MouseUp?.Invoke(this, e); if (InvalidateOnMouseDownUp) { Invalidate(); } }
private void IsMouseUp(OpenTK.Input.MouseState state) { MouseUp?.Invoke(new MouseState { Action = MouseAction.Up, Button = Button == OpenTK.Input.MouseButton.Left ? MouseButton.Left : MouseButton.Right, X = X, Y = Y }); }
private void Panel_MouseUp(object sender, MouseEventArgs e) { if (!mouseDown) { return; } mouseDown = false; Panel.MouseMove -= Panel_MouseMove; MouseUp?.Invoke(e.Location); }