private void CreateDelegates(GameInfo gameInfo, IGameState waitState) { _clickPlayer = (p, location) => PlayerClicked(p, location, gameInfo, waitState); foreach (var player in gameInfo.PlayerList.Where(i => i != gameInfo.CurrentPlayer)) { player.ListenMouseDown += _clickPlayer; player.ListenMouseOver += PlayerMouseIn; player.ListenMouseOut += PlayerMouseOut; gameInfo.AddLowPriorityTarget(player); } }
public static void TravelToNodes(List<Node> possibleNodes, GameInfo gameInfo, MouseDown<Node> callback, bool createCameratTargets = true) { gameInfo.PanCameraToObject(gameInfo.CurrentPlayer); gameInfo.CreateMessage("Choose your destination!"); _cleanupCallback = (node, location) => CleanUp(node, location, gameInfo); _callback = callback; _possibleNodes = possibleNodes; foreach (var possibleNode in possibleNodes) { possibleNode.RememberColorState(ColorState.Glow); possibleNode.SetColorState(ColorState.Glow); possibleNode.ListenMouseDown += callback; possibleNode.ListenMouseDown += _cleanupCallback; if (createCameratTargets) { gameInfo.AddLowPriorityTarget(possibleNode); } } }
public virtual void OnMouseDown(MouseEventArgs e) { if (!_enabled) { return; } Activate(); TrySort(); if (_movable) { Moving = true; _movePoint = CMain.MPoint.Subtract(Location); } if (MouseDown != null) { MouseDown.Invoke(this, e); } }
public bool PreFilterMessage(ref Message m) { uint pos = GetMessagePos(); short x = (short)(pos & 0x0000ffff); short y = (short)((pos & 0xffff0000) >> 16); switch (m.Msg) { case WM_LBUTTONDOWN: { MouseDown.Execute(new System.Drawing.Point(x, y)); break; } case WM_LBUTTONUP: { MouseUp.Execute(new System.Drawing.Point(x, y)); break; } } return(false); }
/// <summary> /// Executa os eventos de mouse. /// </summary> public void MouseButtons() { if (Enabled) { if (InsideButton()) { if (!moveButton) { moveButton = true; MouseMove?.Invoke(this, EventArgs.Empty); } if (EngineCore.MouseDown) { if (!click) { MouseDown?.Invoke(this, EventArgs.Empty); click = true; } } else { if (click) { MouseUp?.Invoke(this, EventArgs.Empty); } click = false; } } else { if (moveButton) { moveButton = false; MouseLeave?.Invoke(this, EventArgs.Empty); } } } }
private IntPtr MBHookProc(int code, IntPtr wParam, IntPtr lParam) { tagMSLLHOOKSTRUCT param = new tagMSLLHOOKSTRUCT(); param = (tagMSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(tagMSLLHOOKSTRUCT)); if (code >= 0 && wParam == (IntPtr)WinAPI.Message.WindowsMessage.LBUTTONDOWN && wParam == (IntPtr)_mb) { MouseDown?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 0, param.x, param.y, 0)); } if (code >= 0 && wParam == (IntPtr)WinAPI.Message.WindowsMessage.RBUTTONDOWN && wParam == (IntPtr)_mb) { MouseDown?.Invoke(this, new MouseEventArgs(MouseButtons.Right, 0, param.x, param.y, 0)); } if (code >= 0 && wParam == (IntPtr)WinAPI.Message.WindowsMessage.MBUTTONDOWN && wParam == (IntPtr)_mb) { MouseDown?.Invoke(this, new MouseEventArgs(MouseButtons.Middle, 0, param.x, param.y, 0)); } if (code >= 0 && wParam == (IntPtr)WinAPI.Message.WindowsMessage.XBUTTONDOWN && wParam == (IntPtr)_mb) { MouseDown?.Invoke(this, new MouseEventArgs((param.mouseData & 0x10000) != 0 ? MouseButtons.XButton1 : MouseButtons.XButton2, 0, param.x, param.y, 0)); } if (code >= 0 && wParam == (IntPtr)WinAPI.Message.WindowsMessage.LBUTTONUP && wParam == (IntPtr)_mb) { MouseUp?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 0, param.x, param.y, 0)); } if (code >= 0 && wParam == (IntPtr)WinAPI.Message.WindowsMessage.RBUTTONUP && wParam == (IntPtr)_mb) { MouseUp?.Invoke(this, new MouseEventArgs(MouseButtons.Right, 0, param.x, param.y, 0)); } if (code >= 0 && wParam == (IntPtr)WinAPI.Message.WindowsMessage.MBUTTONUP && wParam == (IntPtr)_mb) { MouseUp?.Invoke(this, new MouseEventArgs(MouseButtons.Middle, 0, param.x, param.y, 0)); } if (code >= 0 && wParam == (IntPtr)WinAPI.Message.WindowsMessage.XBUTTONUP && wParam == (IntPtr)_mb) { MouseUp?.Invoke(this, new MouseEventArgs((param.mouseData & 0x10000) != 0 ? MouseButtons.XButton1 : MouseButtons.XButton2, 0, param.x, param.y, 0)); } return(WinAPI.Hook.CallNextHookEx(_mbHHook, code, wParam, lParam)); }
public virtual void OnMouseDown(MouseEventArgs e) { if (!_Enabled) { return; } ActiveControl = this; TrySort(); if (_Movable) { Moving = true; MovePoint = Functions.PointS(e.Location, Location); } if (MouseDown != null) { MouseDown.Invoke(this, e); } }
public virtual void Update(float deltaTime) { PreUpdate?.Invoke(deltaTime); if (!enabled) { return; } if (IsMouseOver) { Hovered?.Invoke(); if ((multiselect && !selectedWidgets.Contains(this)) || selectedWidgets.None()) { selectedWidgets.Add(this); Selected?.Invoke(); } } else if (selectedWidgets.Contains(this)) { selectedWidgets.Remove(this); Deselected?.Invoke(); } if (IsSelected) { if (PlayerInput.LeftButtonDown()) { MouseDown?.Invoke(); } if (PlayerInput.LeftButtonHeld()) { MouseHeld?.Invoke(deltaTime); } if (PlayerInput.LeftButtonClicked()) { MouseUp?.Invoke(); } } PostUpdate?.Invoke(deltaTime); }
private void HandleClickActions(CanvasTransform t, IReadOnlyList <BonsaiNode> nodes, Event e) { if (IsClickAction(e)) { clickTimer.Start(); MouseDown?.Invoke(this, CreateInputEvent(t, nodes)); } else if (IsUnlickAction(e)) { BonsaiInputEvent inputEvent = CreateInputEvent(t, nodes); // A node click is registered if below a time threshold. if (clickTimer.Enabled) { Click?.Invoke(this, inputEvent); } // Reset for next click. clickTimer.Stop(); MouseUp?.Invoke(this, inputEvent); } }
public virtual void onMouseDown(object sender, MouseButtonEventArgs e){ if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick) onMouseDoubleClick (this, e); else currentInterface.clickTimer.Restart(); CurrentInterface.eligibleForDoubleClick = null; if (CurrentInterface.ActiveWidget == null) CurrentInterface.ActiveWidget = this; if (this.Focusable && !Interface.FocusOnHover) { BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg; if (be.Focused == null) { be.Focused = this; CurrentInterface.FocusedWidget = this; } } //bubble event to the top GraphicObject p = Parent as GraphicObject; if (p != null) p.onMouseDown(sender,e); MouseDown.Raise (this, e); }
private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { MSLLHOOKSTRUCT mouseHookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); if (wParam.ToInt32() == WM_LBUTTONDOWN) { if (MouseDown != null) { MouseDown.Invoke(null, new System.Drawing.Point(mouseHookStruct.pt.x, mouseHookStruct.pt.y)); } } if (wParam.ToInt32() == WM_MOUSEWHEEL) { if (MouseWheel != null) { MouseDevice mouseDev = InputManager.Current.PrimaryMouseDevice; MouseWheel.Invoke(null, new MouseWheelEventArgs(mouseDev, Environment.TickCount, (int)mouseHookStruct.mouseData >> 16)); } } } return(CallNextHookEx(_mouseHookHandle, nCode, wParam, lParam)); }
public WpfMouseInput(UIElement element) { element.AddHandler(UIElement.PreviewMouseDownEvent, new MouseButtonEventHandler((sender, args) => MouseDown?.Invoke(element, new MouseButtonEventArgs( args.ChangedButton, args.GetPosition(element), args.ClickCount))), true); element.AddHandler(UIElement.PreviewMouseUpEvent, new MouseButtonEventHandler((sender, args) => MouseUp?.Invoke(element, new MouseButtonEventArgs( args.ChangedButton, args.GetPosition(element), args.ClickCount))), true); element.AddHandler(UIElement.PreviewMouseWheelEvent, new MouseWheelEventHandler((sender, args) => MouseWheel?.Invoke(element, new MouseWheelEventArgs(args.Delta))), true); element.AddHandler(UIElement.PreviewMouseMoveEvent, new MouseEventHandler((sender, args) => MouseMove?.Invoke(element, new MouseMoveEventArgs(args.GetPosition(element)))), true); _element = element; }
private void UpdateMouseState() { var position = ViewportAdapter.PointToScreen(InputManager.ClickPosition()); if (BoundingRectangle().Intersects(new Rectangle(position, Point.Zero))) { if (InputManager.Clicked()) { _mouseDown = true; MouseDown?.Invoke(this, position); } else if (InputManager.LeftClickReleased() && _mouseDown) { _mouseDown = false; Click?.Invoke(this, position); Action?.Invoke(this, position); } } else { _mouseDown = false; } }
public virtual bool OnJudge(GameBase game) { var mouse = Input.Mouse.Position; if (Intersect(mouse)) { if (prevMouse != mouse) { MouseMove?.Invoke(this); } if (Input.Mouse.IsLeftDown) { MouseDown?.Invoke(this); } if (Input.Mouse.IsLeftUp) { MouseUp?.Invoke(this); } return(true); } prevMouse = mouse; return(false); }
public override IGameState[] PerformLogic(GameTime gameTime, GameInfo gameInfo) { if (inBet) { return(EvaluateSpinToWinWinners(gameInfo)); } var waitStateAlert = StateFactory.GetState(GameStates.GameStates.Wait); var alert = new Alert(gameInfo.Manager, "Spin to Win!\n" + "Each player will click the spinner to place their bets!\n" + gameInfo.CurrentPlayer.Name + " will be allowed to place two bets", "Spin to Win", icon: Constants.ImageIcons.SpinToWin); gameInfo.Manager.Add(alert); alert.Closed += (sender, args) => gameInfo.Fsm.Remove(waitStateAlert); waitState = StateFactory.GetState(GameStates.GameStates.Wait); inBet = true; var gameSpinner = gameInfo.Spinner; gameSpinner.DrawHighlights = true; gameSpinner.HighlightedSections = new Color[10]; PlacedBets = new Player[10]; playerNum = -1; if (placeBetDelegate == null) { placeBetDelegate = (spinner, location) => TakePlayerBet(gameInfo, spinner, location); } gameInfo.PanCameraToObject(gameSpinner); gameInfo.Spinner.ListenMouseDown += placeBetDelegate; TakeNextPlayerBet(gameInfo); return(new[] { this, StateFactory.GetState(GameStates.GameStates.Spin), waitState, waitStateAlert }); }
private void CustomMenuItem_MouseDown(object sender, EventArgs e) { MouseDown?.Invoke(sender, e); }
/// <inheritdoc cref="MouseDown" /> private void ControlOnMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs args) => MouseDown?.Invoke(sender, new MouseEventArgs(args, GetPosition(args), 0));
internal void RaiseMouseDown(MouseButton btn) { _down.Add(btn); MouseDown?.Invoke(this, btn); }
private void OnMouseDown() { MouseDown.Invoke(); }
/// <summary> /// Invokes the MouseDown event. /// </summary> /// <param name="v">Location of the mouse.</param> /// <param name="b">The current state of the mouse buttons.</param> internal void DoMouseDown(Vec2 v, MouseButtons b) { MouseDown.Invoke(v, b); }
private void Handle(DateTime time, RawMouseButtons state, InputMouse data) { IPoint coords = new Point(data.X, data.Y, !data.Flags.HasFlag(RawMouseFlags.MoveAbsolute)); int delta = data.Data.WheelDelta; switch (state) { case RawMouseButtons.None when data.X != 0 || data.Y != 0 || !coords.IsRelative: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Movement, coords, delta, MouseButtons.None, KeyState.None, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseMove?.Invoke(this, eventArgs); break; } case RawMouseButtons.LeftDown: { int currentTime = (int)Kernel32.DateTimeToTicks(time); bool isDoubleClick = currentTime - LastLeftClick <= User32.DoubleClickTime; Interlocked.Exchange(ref LastLeftClick, currentTime - (isDoubleClick ? User32.DoubleClickTime + 1 : 0)); IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, MouseButtons.Left, KeyState.Down, isDoubleClick, time, false); OnEvent?.Invoke(this, eventArgs); MouseDown?.Invoke(this, eventArgs); MouseClick?.Invoke(this, eventArgs); if (isDoubleClick) { MouseDoubleClick?.Invoke(this, eventArgs); } break; } case RawMouseButtons.MiddleDown: case RawMouseButtons.RightDown: case RawMouseButtons.Button4Down: case RawMouseButtons.Button5Down: { MouseButtons button = state switch { RawMouseButtons.MiddleDown => MouseButtons.Middle, RawMouseButtons.RightDown => MouseButtons.Right, RawMouseButtons.Button4Down => MouseButtons.XButton1, RawMouseButtons.Button5Down => MouseButtons.XButton2, _ => MouseButtons.None }; IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, button, KeyState.Down, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseDown?.Invoke(this, eventArgs); MouseClick?.Invoke(this, eventArgs); break; } case RawMouseButtons.LeftUp: case RawMouseButtons.MiddleUp: case RawMouseButtons.RightUp: case RawMouseButtons.Button4Up: case RawMouseButtons.Button5Up: { MouseButtons button = state switch { RawMouseButtons.LeftUp => MouseButtons.Left, RawMouseButtons.MiddleUp => MouseButtons.Middle, RawMouseButtons.RightUp => MouseButtons.Right, RawMouseButtons.Button4Up => MouseButtons.XButton1, RawMouseButtons.Button5Up => MouseButtons.XButton2, _ => MouseButtons.None }; IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, button, KeyState.Up, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseUp?.Invoke(this, eventArgs); break; } case RawMouseButtons.Wheel: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Wheel, coords, delta, MouseButtons.Wheel, delta > 0 ? KeyState.Up : KeyState.Down, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseWheel?.Invoke(this, eventArgs); break; } case RawMouseButtons.HWheel: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.HorizontalWheel, coords, delta, MouseButtons.Wheel, delta > 0 ? KeyState.Up : KeyState.Down, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseHorizontalWheel?.Invoke(this, eventArgs); break; } default: break; } }
/// <summary> /// Method triggered when MouseDown event is fired on the TreeListView. Raises MouseDown event.</summary> /// <param name="e">Mouse event arguments</param> protected virtual void OnMouseDown(MouseEventArgs e) { MouseDown.Raise(this, e); }
protected virtual void OnMouseDown(int x, int y, Input.MouseEventsContext context) { MouseDown?.Invoke(this, new Input.MouseEventArgs(context.MouseButtons, context.Clicks, x, y, context.Delta)); }
/// <summary> /// マウスボタンの押下時に呼ばれます。 /// </summary> public virtual void OnMouseDown(MouseEventArgs e) { ForeachChildren(_ => _.OnMouseDown(e)); MouseDown.SafeRaiseEvent(this, e); }
public virtual void HandleMouseDown(Point mousepos, MouseButtons mouseButtons) { MouseDown?.Invoke(this, mousepos, mouseButtons); }
public virtual void OnMouseDown(MouseButtons mb) { MouseDown?.Invoke(this, new GenericEventArgs <MouseButtons>(mb)); }
/// <summary> /// Raises the <see cref="E:MouseDown"/> event. /// </summary> /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param> protected virtual void OnMouseDown(MouseEventArgs e) { MouseDown?.Invoke(this, e); }
private void init(GameWindow game) { if (_game != null) { return; } _game = game; _originalOSCursor = game.Cursor; _cursor.PropertyChanged += (sender, e) => { if (_cursor.Cursor != null) { _game.Cursor = MouseCursor.Empty; } }; game.MouseDown += (sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); _actions.Enqueue(() => MouseDown.InvokeAsync(new API.MouseButtonEventArgs(_hitTest.ObjectAtMousePosition, button, MousePosition))); }; game.MouseUp += (sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); _actions.Enqueue(() => MouseUp.InvokeAsync(new API.MouseButtonEventArgs(_hitTest.ObjectAtMousePosition, button, MousePosition))); }; game.MouseMove += (sender, e) => { _mouseX = e.Mouse.X; _mouseY = e.Mouse.Y; _actions.Enqueue(() => MouseMove.InvokeAsync(new MousePositionEventArgs(MousePosition))); }; game.KeyDown += (sender, e) => { API.Key key = convert(e.Key); _keysDown.Add(key); if (isInputBlocked()) { return; } _actions.Enqueue(() => KeyDown.InvokeAsync(new KeyboardEventArgs(key))); }; game.KeyUp += (sender, e) => { API.Key key = convert(e.Key); _keysDown.Remove(key); if (isInputBlocked()) { return; } _actions.Enqueue(() => KeyUp.InvokeAsync(new KeyboardEventArgs(key))); }; _events.OnRepeatedlyExecuteAlways.Subscribe(onRepeatedlyExecute); }
/// <inheritdoc cref="MouseDown" /> private void ControlOnMouseDown(object sender, System.Windows.Forms.MouseEventArgs args) => MouseDown?.Invoke(sender, new MouseEventArgs(args));
private void CustomContextMenu_MouseDown(object sender, EventArgs e) { MouseDown?.Invoke(sender, e); }
public virtual void OnMouseDown(Point position) { IsDragging = true; MouseDown?.Invoke(this, new MouseEventArgs(MouseButtons.Left, 1, position.X, position.Y, 0)); }
private void Update() { if (IsLocked) { return; } var mousePosition = Input.mousePosition; if (IsOverGui()) { _isMouseDown = false; _isMouseMove = false; _isOneClick = false; _previousMousePosition = null; return; } float mouseWheel = Input.GetAxis("Mouse ScrollWheel"); if (mouseWheel != 0) { MouseWheel?.Invoke(mouseWheel); } if (Input.GetKeyDown(KeyCode.Mouse0)) { _isMouseDown = true; _isMouseMove = false; _buttonDownPosition = mousePosition; _previousMousePosition = null; if (!_isOneClick) { _isOneClick = true; _doubleClickTime = Time.time; MouseDown?.Invoke(mousePosition); IsOverGui(); } else { _isOneClick = false; MouseDoubleClick?.Invoke(mousePosition); _buttonDownPosition = mousePosition; return; } } if (_isOneClick && Time.time - _doubleClickTime > Delay) { _isOneClick = false; } if (!_isMouseDown) { return; } if (Input.GetKeyUp(KeyCode.Mouse0)) { _isMouseDown = false; MouseUp?.Invoke(mousePosition); if (!_isMouseMove) { MouseClick?.Invoke(mousePosition); _isMouseMove = false; } _buttonDownPosition = null; _previousMousePosition = null; return; } if (_buttonDownPosition != null) { if (_previousMousePosition != null) { if (Vector3.Distance(_previousMousePosition.Value, mousePosition) > DeltaRegistration) { _isOneClick = false; _isMouseMove = true; MouseMove?.Invoke(mousePosition, _previousMousePosition.Value); _previousMousePosition = mousePosition; } } else { if (Vector3.Distance(_buttonDownPosition.Value, mousePosition) > DeltaRegistration) { _isOneClick = false; _isMouseMove = true; MouseMove?.Invoke(mousePosition, _buttonDownPosition.Value); _previousMousePosition = mousePosition; } } } }