/// <summary> /// Raises the <see cref="MouseMove"/> event. /// </summary> /// <param name="state">Current mouse state in relation to this console.</param> protected virtual void OnMouseMove(MouseConsoleState state) { MouseMove?.Invoke(this, new MouseEventArgs(state)); }
private void WndProc(ref Message message) { switch (message.Msg) { case WM_DESTROY: UpdateNotifyIcon(false); return; case WM_COMMAND: if (message.LParam != IntPtr.Zero) { _window.DefWndProc(ref message); return; } _commandDispatch.Invoke(null, new object[] { message.WParam.ToInt32()& 0xFFFF }); return; case WM_INITMENUPOPUP: ProcessInitMenuPopup(ref message); return; case WM_TRAYMOUSEMESSAGE: switch ((int)message.LParam) { case WM_MOUSEMOVE: MouseMove?.Invoke(this, new MouseEventArgs(Control.MouseButtons, 0, 0, 0, 0)); return; case WM_LBUTTONDOWN: ProcessMouseDown(MouseButtons.Left, false); return; case WM_LBUTTONUP: ProcessMouseUp(MouseButtons.Left); return; case WM_LBUTTONDBLCLK: ProcessMouseDown(MouseButtons.Left, true); return; case WM_RBUTTONDOWN: ProcessMouseDown(MouseButtons.Right, false); return; case WM_RBUTTONUP: if (ContextMenu != null || ContextMenuStrip != null) { ShowContextMenu(); } ProcessMouseUp(MouseButtons.Right); return; case WM_RBUTTONDBLCLK: ProcessMouseDown(MouseButtons.Right, true); return; case WM_MBUTTONDOWN: ProcessMouseDown(MouseButtons.Middle, false); return; case WM_MBUTTONUP: ProcessMouseUp(MouseButtons.Middle); return; case WM_MBUTTONDBLCLK: ProcessMouseDown(MouseButtons.Middle, true); return; case NIN_BALLOONSHOW: BalloonTipShown?.Invoke(this, EventArgs.Empty); return; case NIN_BALLOONHIDE: case NIN_BALLOONTIMEOUT: BalloonTipClosed?.Invoke(this, EventArgs.Empty); return; case NIN_BALLOONUSERCLICK: BalloonTipClicked?.Invoke(this, EventArgs.Empty); return; default: return; } } if (message.Msg == _wmTaskBarCreated) { lock (_syncObj) { _created = false; } UpdateNotifyIcon(_visible); } _window.DefWndProc(ref message); }
/// <summary> /// Called when the mouse is moved. /// </summary> /// <param name="move">The mouse move input.</param> public virtual void OnMouseMove(MouseMove move) { var position = Mouse.Position; if (this.Captured != null) { this.Highlighted = this.HitTest<Control>(position).FirstOrDefault(i => i.CanHighlight && i.IsEnabled && i == this.Captured); this.Captured.RaiseEvent(PreviewMouseMoveEvent, MouseMoveEvent, new MouseMotionEventArgs(move, position)); } else { this.Highlighted = this.HitTest<Control>(position).FirstOrDefault(i => i.CanHighlight && i.IsEnabled); foreach (var element in this.HitTest<UIElement>(position)) { element.RaiseEvent(PreviewMouseMoveEvent, MouseMoveEvent, new MouseMotionEventArgs(move, position)); break; } } }
/// <summary> /// Allows for inheriting tools to control OnMouseMove. /// </summary> /// <param name="e">A GeoMouseArgs parameter</param> protected virtual void OnMouseMove(GeoMouseArgs e) { MouseMove?.Invoke(this, e); }
public void FireMouseMove(MouseMoveEventArgs e) { MouseMove?.Invoke(this, e); }
//public string update = ""; #endregion #region Mouse Handling void Mouse_Move(object sender, MouseMoveEventArgs e) { if (_activeWidget != null) { //first, ensure object is still in the graphic tree if (_activeWidget.HostContainer == null) { activeWidget = null; } else { //send move evt even if mouse move outside bounds _activeWidget.onMouseMove(_activeWidget, e); return; } } if (_hoverWidget != null) { //first, ensure object is still in the graphic tree if (_hoverWidget.HostContainer == null) { hoverWidget = null; } else { //check topmost graphicobject first GraphicObject tmp = _hoverWidget; GraphicObject topc = null; while (tmp is GraphicObject) { topc = tmp; tmp = tmp.Parent as GraphicObject; } int idxhw = GraphicObjects.IndexOf(topc); if (idxhw != 0) { int i = 0; while (i < idxhw) { if (GraphicObjects [i].MouseIsIn(e.Position)) { _hoverWidget.onMouseLeave(this, e); GraphicObjects [i].checkHoverWidget(e); return; } i++; } } if (_hoverWidget.MouseIsIn(e.Position)) { _hoverWidget.checkHoverWidget(e); return; } else { _hoverWidget.onMouseLeave(this, e); //seek upward from last focused graph obj's while (_hoverWidget.Parent as GraphicObject != null) { _hoverWidget = _hoverWidget.Parent as GraphicObject; if (_hoverWidget.MouseIsIn(e.Position)) { _hoverWidget.checkHoverWidget(e); return; } else { _hoverWidget.onMouseLeave(this, e); } } } } } //top level graphic obj's parsing for (int i = 0; i < GraphicObjects.Count; i++) { GraphicObject g = GraphicObjects[i]; if (g.MouseIsIn(e.Position)) { g.checkHoverWidget(e); PutOnTop(g); return; } } _hoverWidget = null; MouseMove.Raise(this, e); }
/// <summary> /// Raises the MouseMove event. Override this method to add code to handle when the mouse is moved /// </summary> /// <param name="e">InputEventCM for the MouseMove event</param> private void invokeMouseMove(InputEventMouse e) { MouseMove?.Invoke(e); }
/// <summary> /// Handling aller Eingaben, Mausbewegungen und Updaten aller Screens und Controls. /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { if (Game.IsActive) { #region Mouse Interaction if (MouseEnabled) { MouseState mouse; Point mousePosition; if (MouseMode == MouseMode.Captured) { mouse = Mouse.GetState(); mousePosition = new Point( mouse.X - (lastMousePosition.X), mouse.Y - (lastMousePosition.Y)); } else { mouse = Mouse.GetCursorState(); mousePosition = Game.Window.PointToClient(mouse.Location); } // Mausposition anhand des Mouse Modes ermitteln MouseEventArgs mouseEventArgs = MouseEventArgsPool.Instance.Take(); mouseEventArgs.MouseMode = MouseMode; mouseEventArgs.GlobalPosition = mousePosition; mouseEventArgs.LocalPosition = mousePosition; // Mouse Move if (mousePosition != lastMousePosition) { mouseEventArgs.Handled = false; root.InternalMouseMove(mouseEventArgs); if (!mouseEventArgs.Handled) { MouseMove?.Invoke(mouseEventArgs); } // Start Drag Handling if (mouse.LeftButton == ButtonState.Pressed && DraggingArgs == null) { DraggingArgs = DragEventArgsPool.Instance.Take(); DraggingArgs.GlobalPosition = mousePosition; DraggingArgs.LocalPosition = mousePosition; draggingId = null; root.InternalStartDrag(DraggingArgs); if (!DraggingArgs.Handled) { StartDrag?.Invoke(DraggingArgs); } } // Drop move if (mouse.LeftButton == ButtonState.Pressed && DraggingArgs != null && draggingId == null && DraggingArgs.Handled) { //TODO: perhaps pool single object? DragEventArgs args = DragEventArgsPool.Instance.Take(); args.GlobalPosition = mousePosition; args.LocalPosition = mousePosition; args.Content = DraggingArgs.Content; args.Icon = DraggingArgs.Icon; args.Sender = DraggingArgs.Sender; root.InternalDropMove(args); if (!args.Handled) { DropMove?.Invoke(args); } } } // Linke Maustaste if (mouse.LeftButton == ButtonState.Pressed) { if (!lastLeftMouseButtonPressed) { mouseEventArgs.Handled = false; // Linke Maustaste wurde neu gedrückt root.InternalLeftMouseDown(mouseEventArgs); if (!mouseEventArgs.Handled) { LeftMouseDown?.Invoke(mouseEventArgs); } } lastLeftMouseButtonPressed = true; } else { if (lastLeftMouseButtonPressed) { // Handle Drop if (DraggingArgs != null && DraggingArgs.Handled) { DragEventArgs args = DragEventArgsPool.Instance.Take(); args.GlobalPosition = mousePosition; args.LocalPosition = mousePosition; args.Content = DraggingArgs.Content; args.Icon = DraggingArgs.Icon; args.Sender = DraggingArgs.Sender; root.InternalEndDrop(args); if (!args.Handled) { EndDrop?.Invoke(args); } } // Discard Dragging Infos DragEventArgsPool.Instance.Release(DraggingArgs); DraggingArgs = null; draggingId = null; // Linke Maustaste wurde losgelassen mouseEventArgs.Handled = false; root.InternalLeftMouseClick(mouseEventArgs); if (!mouseEventArgs.Handled) { LeftMouseClick?.Invoke(mouseEventArgs); } if (lastLeftClick.HasValue && gameTime.TotalGameTime - lastLeftClick.Value < TimeSpan.FromMilliseconds(DoubleClickDelay)) { // Double Left Click mouseEventArgs.Handled = false; root.InternalLeftMouseDoubleClick(mouseEventArgs); if (!mouseEventArgs.Handled) { LeftMouseDoubleClick?.Invoke(mouseEventArgs); } lastLeftClick = null; } else { lastLeftClick = gameTime.TotalGameTime; } // Mouse Up mouseEventArgs.Handled = false; root.InternalLeftMouseUp(mouseEventArgs); if (!mouseEventArgs.Handled) { LeftMouseUp?.Invoke(mouseEventArgs); } } lastLeftMouseButtonPressed = false; } // Rechte Maustaste if (mouse.RightButton == ButtonState.Pressed) { if (!lastRightMouseButtonPressed) { // Rechte Maustaste neu gedrückt mouseEventArgs.Handled = false; root.InternalRightMouseDown(mouseEventArgs); if (!mouseEventArgs.Handled) { RightMouseDown?.Invoke(mouseEventArgs); } } lastRightMouseButtonPressed = true; } else { if (lastRightMouseButtonPressed) { // Rechte Maustaste losgelassen mouseEventArgs.Handled = false; root.InternalRightMouseClick(mouseEventArgs); if (!mouseEventArgs.Handled) { RightMouseClick?.Invoke(mouseEventArgs); } if (lastRightClick.HasValue && gameTime.TotalGameTime - lastRightClick.Value < TimeSpan.FromMilliseconds(DoubleClickDelay)) { // Double Left Click mouseEventArgs.Handled = false; root.InternalRightMouseDoubleClick(mouseEventArgs); if (!mouseEventArgs.Handled) { RightMouseDoubleClick?.Invoke(mouseEventArgs); } lastRightClick = null; } else { lastRightClick = gameTime.TotalGameTime; } mouseEventArgs.Handled = false; root.InternalRightMouseUp(mouseEventArgs); if (!mouseEventArgs.Handled) { RightMouseUp?.Invoke(mouseEventArgs); } } lastRightMouseButtonPressed = false; } // Mousewheel if (lastMouseWheelValue != mouse.ScrollWheelValue) { int diff = (mouse.ScrollWheelValue - lastMouseWheelValue); MouseScrollEventArgs scrollArgs = new MouseScrollEventArgs { MouseMode = MouseMode, GlobalPosition = mousePosition, LocalPosition = mousePosition, Steps = diff }; root.InternalMouseScroll(scrollArgs); if (!scrollArgs.Handled) { MouseScroll?.Invoke(scrollArgs); } lastMouseWheelValue = mouse.ScrollWheelValue; } // Potentieller Positionsreset if (MouseMode == MouseMode.Free) { lastMousePosition = mousePosition; } else if (mousePosition.X != 0 || mousePosition.Y != 0) { lastMousePosition = mouse.Location; } MouseEventArgsPool.Instance.Release(mouseEventArgs); } #endregion #region Keyboard Interaction if (KeyboardEnabled) { KeyboardState keyboard = Keyboard.GetState(); bool shift = keyboard.IsKeyDown(Keys.LeftShift) | keyboard.IsKeyDown(Keys.RightShift); bool ctrl = keyboard.IsKeyDown(Keys.LeftControl) | keyboard.IsKeyDown(Keys.RightControl); bool alt = keyboard.IsKeyDown(Keys.LeftAlt) | keyboard.IsKeyDown(Keys.RightAlt); KeyEventArgs args; for (int i = 0; i < _pressedKeys.Length; i++) { var key = (Keys)i; if (keyboard.IsKeyDown(key)) { // ReSharper disable once CompareOfFloatsByEqualityOperator if (_pressedKeys[i] == UnpressedKeyTimestamp) { // Taste ist neu args = KeyEventArgsPool.Take(); args.Key = key; args.Shift = shift; args.Ctrl = ctrl; args.Alt = alt; root.InternalKeyDown(args); if (!args.Handled) { KeyDown?.Invoke(args); } KeyEventArgsPool.Release(args); args = KeyEventArgsPool.Take(); args.Key = key; args.Shift = shift; args.Ctrl = ctrl; args.Alt = alt; root.InternalKeyPress(args); _pressedKeys[i] = gameTime.TotalGameTime.TotalMilliseconds + 500; KeyEventArgsPool.Release(args); // Spezialfall Tab-Taste (falls nicht verarbeitet wurde) if (key == Keys.Tab && !args.Handled) { if (shift) { root.InternalTabbedBackward(); } else { root.InternalTabbedForward(); } } } else { // Taste ist immernoch gedrückt if (_pressedKeys[i] <= gameTime.TotalGameTime.TotalMilliseconds) { args = KeyEventArgsPool.Take(); args.Key = key; args.Shift = shift; args.Ctrl = ctrl; args.Alt = alt; root.InternalKeyPress(args); if (!args.Handled) { KeyPress?.Invoke(args); } KeyEventArgsPool.Release(args); _pressedKeys[i] = gameTime.TotalGameTime.TotalMilliseconds + 50; } } } else { // ReSharper disable once CompareOfFloatsByEqualityOperator if (_pressedKeys[i] != UnpressedKeyTimestamp) { // Taste losgelassen args = KeyEventArgsPool.Take(); args.Key = key; args.Shift = shift; args.Ctrl = ctrl; args.Alt = alt; root.InternalKeyUp(args); _pressedKeys[i] = UnpressedKeyTimestamp; if (!args.Handled) { KeyUp?.Invoke(args); } KeyEventArgsPool.Release(args); } } } } #endregion #region Touchpanel Interaction //if (TouchEnabled) //{ // TouchCollection touchPoints = TouchPanel.GetState(); // foreach (var touchPoint in touchPoints) // { // Point point = touchPoint.Position.ToPoint(); // TouchEventArgs args = new TouchEventArgs() // { // TouchId = touchPoint.Id, // GlobalPosition = point, // LocalPosition = point // }; // switch (touchPoint.State) // { // case TouchLocationState.Pressed: // root.InternalTouchDown(args); // if (!args.Handled && TouchDown != null) // TouchDown(args); // break; // case TouchLocationState.Moved: // // Touch Move // root.InternalTouchMove(args); // if (!args.Handled && TouchMove != null) // TouchMove(args); // // Start Dragging // if (DraggingArgs == null) // { // DraggingArgs = new DragEventArgs() // { // GlobalPosition = point, // LocalPosition = point, // }; // draggingId = touchPoint.Id; // root.InternalStartDrag(DraggingArgs); // if (!DraggingArgs.Handled && StartDrag != null) // StartDrag(DraggingArgs); // } // // Drop move // if (DraggingArgs != null && // draggingId == touchPoint.Id && // DraggingArgs.Handled) // { // DragEventArgs moveArgs = new DragEventArgs() // { // GlobalPosition = point, // LocalPosition = point, // Content = DraggingArgs.Content, // Icon = DraggingArgs.Icon, // Sender = DraggingArgs.Sender // }; // root.InternalDropMove(moveArgs); // if (!args.Handled && DropMove != null) // DropMove(moveArgs); // } // break; // case TouchLocationState.Released: // // Handle Drop // if (DraggingArgs != null && // draggingId == touchPoint.Id && // DraggingArgs.Handled) // { // DragEventArgs dropArgs = new DragEventArgs() // { // GlobalPosition = point, // LocalPosition = point, // Content = DraggingArgs.Content, // Icon = DraggingArgs.Icon, // Sender = DraggingArgs.Sender // }; // root.InternalEndDrop(dropArgs); // if (!args.Handled && EndDrop != null) // EndDrop(dropArgs); // } // // Discard Dragging Infos // DraggingArgs = null; // draggingId = null; // // Linke Maustaste wurde losgelassen // TouchEventArgs tapArgs = new TouchEventArgs // { // TouchId = touchPoint.Id, // GlobalPosition = point, // LocalPosition = point // }; // root.InternalTouchTap(tapArgs); // if (!tapArgs.Handled && TouchTap != null) // TouchTap(tapArgs); // if (lastTouchTap.HasValue && // gameTime.TotalGameTime - lastLeftClick.Value < TimeSpan.FromMilliseconds(DoubleClickDelay)) // { // // Double Tap // TouchEventArgs doubleTapArgs = new TouchEventArgs // { // TouchId = touchPoint.Id, // GlobalPosition = point, // LocalPosition = point // }; // root.InternalTouchDoubleTap(doubleTapArgs); // if (!doubleTapArgs.Handled && TouchDoubleTap != null) // TouchDoubleTap(doubleTapArgs); // lastTouchTap = null; // } // else // { // lastTouchTap = gameTime.TotalGameTime; // } // root.InternalTouchUp(args); // if (!args.Handled && TouchUp != null) // TouchUp(args); // break; // } // } //} #endregion } #region Recalculate Sizes if (root.HasInvalidDimensions()) { Point available = new Point(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); Point required = root.GetExpectedSize(available); root.SetActualSize(available); } root.Update(gameTime); #endregion #region Form anpassen if (_titleDirty || (ActiveScreen?.Title != _lastActiveScreenTitle)) { string screentitle = ActiveScreen?.Title ?? string.Empty; string windowtitle = TitlePrefix + (string.IsNullOrEmpty(screentitle) ? string.Empty : " - " + screentitle); if (Game.Window != null && Game.Window.Title != windowtitle) { Game.Window.Title = windowtitle; } _titleDirty = false; _lastActiveScreenTitle = ActiveScreen?.Title; } #endregion }
private void process(int nCode, IntPtr wParam, IntPtr lParam) { /* lParam * pt POINT LONG LONG 32bit 4byte*2 offset:0~7 * mouseData DWORD 32BIT 4byte offset:8~11 * flags DWORD 32bit 4byte offset:12~15 * time DWORD 32bit 4byte offset 16~19 * WParam * */ int x = Marshal.ReadInt32(lParam, 0); int y = Marshal.ReadInt32(lParam, 4); System.Drawing.Point point = new System.Drawing.Point(x, y); MouseEvent me = (MouseEvent)wParam.ToInt32(); if (me == MouseEvent.MouseMove) { MouseMove?.Invoke(this, new MouseMoveEventArgs(point)); } else if (me == MouseEvent.MouseRightButtonDown || me == MouseEvent.MouseLeftButtonDown || me == MouseEvent.MiddleButtonDown) { MouseKey mouseKey = MouseKey.LeftButton; switch (me) { case (MouseEvent.MouseRightButtonDown): mouseKey = MouseKey.RightButton; break; case (MouseEvent.MouseLeftButtonDown): mouseKey = MouseKey.LeftButton; break; case (MouseEvent.MiddleButtonDown): mouseKey = MouseKey.MiddleButton; break; } MouseKeyDown?.Invoke(this, new MouseKeyEventArgs(mouseKey, point)); } else if (me == MouseEvent.MouseRightButtonUp || me == MouseEvent.MouseLeftButtonUp || me == MouseEvent.MiddleButtonUp) { MouseKey mouseKey = MouseKey.LeftButton; switch (me) { case (MouseEvent.MouseRightButtonUp): mouseKey = MouseKey.RightButton; break; case (MouseEvent.MouseLeftButtonUp): mouseKey = MouseKey.LeftButton; break; case (MouseEvent.MiddleButtonUp): mouseKey = MouseKey.MiddleButton; break; } MouseKeyUp?.Invoke(this, new MouseKeyEventArgs(mouseKey, point)); } else if (me == MouseEvent.MouseWhell) { MouseWhell?.Invoke(this, new MouseWhellEventArgs(point)); } Debug.Print(((MouseEvent)wParam.ToInt32()).ToString()); CallNextHookEx(Hook, nCode, wParam, lParam); }
protected bool DoMouseMove(MouseEventArgs e) { MouseMove?.Invoke(this, e); return(MouseMove != null); }
/// <summary> /// コンストラクタ。 /// </summary> public CanvasContext(TextEditorComponent textEditorComponent, IJSInProcessRuntime jsRuntime, JSEvent jsEvent) { _textEditorComponent = textEditorComponent; _jsRuntime = jsRuntime; _textEditorComponent.Created += size => { jsEvent.RegisterActionListener("TextEditorComponent.resize", args => Resize?.Invoke(ToSize(args))); jsEvent.RegisterActionListener("TextEditorComponent.mousedown", args => MouseDown?.Invoke(ToMouseState(args))); jsEvent.RegisterActionListener("TextEditorComponent.mouseup", args => MouseUp?.Invoke(ToMouseState(args))); jsEvent.RegisterActionListener("TextEditorComponent.mousemove", args => MouseMove?.Invoke(ToMouseState(args))); jsEvent.RegisterActionListener("TextEditorComponent.mousewheel", args => MouseWheel?.Invoke(ToMouseState(args))); jsEvent.RegisterActionListener("TextEditorComponent.render", _ => RenderFrame?.Invoke(new RenderingContext(_textEditorComponent))); jsEvent.RegisterActionListener("InputMethod.focusin", args => GotFocus?.Invoke()); jsEvent.RegisterActionListener("InputMethod.focusout", args => LostFocus?.Invoke()); Created?.Invoke(size); }; }
private void OnMouseMove(FieldCoords coords) { MouseMove?.Invoke(this, coords); }
private void init(GameWindow game) { if (_game != null) { return; } _game = game; this._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 AGS.API.MouseButtonEventArgs(_hitTest.ObjectAtMousePosition, button, MousePosition))); }; game.MouseUp += (sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); _actions.Enqueue(() => MouseUp.InvokeAsync(new AGS.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); }
/// <summary> /// Raises the <see cref="MouseMove"/> event /// </summary> /// <param name="e"></param> protected virtual void OnMouseMove(MouseEventArgs e) { MouseMove?.Invoke(this, e); }
void IEventListener.ListenMouseMove(UIMouseEventArgs e) { MouseMove?.Invoke(e); }
public void MouseMoveCB(WindowEvent e) { MouseMove?.Invoke(e); }
public void Forward(object sender, MouseMoveEventArgs e) => MouseMove?.Invoke(sender, e);
public virtual void OnMouseMove(MouseEventArgs e) { if (!_enabled) { return; } if (Moving) { Point tempPoint = CMain.MPoint.Subtract(_movePoint); if (Parent == null) { if (tempPoint.Y + TrueSize.Height > Settings.ScreenHeight) { tempPoint.Y = Settings.ScreenHeight - TrueSize.Height - 1; } if (tempPoint.X + TrueSize.Width > Settings.ScreenWidth) { tempPoint.X = Settings.ScreenWidth - TrueSize.Width - 1; } } else { if (tempPoint.Y + TrueSize.Height > Parent.TrueSize.Height) { tempPoint.Y = Parent.TrueSize.Height - TrueSize.Height; } if (tempPoint.X + TrueSize.Width > Parent.TrueSize.Width) { tempPoint.X = Parent.TrueSize.Width - TrueSize.Width; } } if (tempPoint.X < 0) { tempPoint.X = 0; } if (tempPoint.Y < 0) { tempPoint.Y = 0; } Location = tempPoint; if (OnMoving != null) { OnMoving.Invoke(this, e); } return; } if (Controls != null) { for (int i = Controls.Count - 1; i >= 0; i--) { if (Controls[i].IsMouseOver(CMain.MPoint)) { Controls[i].OnMouseMove(e); return; } } } Highlight(); if (MouseMove != null) { MouseMove.Invoke(this, e); } }
/// <summary> /// Goes through each key checking it's state compared to the last /// frame, triggering events if necessary. Updates the current mouse /// state and triggers events if necessary. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime) { #region Update Keyboard // Create the Arguments class and fill in with the modifier data KeyEventArgs keyEvent = new KeyEventArgs(); foreach (Keys key in Keyboard.GetState().GetPressedKeys()) { if (key == Keys.LeftAlt || key == Keys.RightAlt) { keyEvent.Alt = true; } else if (key == Keys.LeftShift || key == Keys.RightShift) { keyEvent.Shift = true; } else if (key == Keys.LeftControl || key == Keys.RightControl) { keyEvent.Control = true; } } // Loop through our keys foreach (InputKey key in this.keys) { // If they are any of the modifier keys, skip them if (key.Key == Keys.LeftAlt || key.Key == Keys.RightAlt || key.Key == Keys.LeftShift || key.Key == Keys.RightShift || key.Key == Keys.LeftControl || key.Key == Keys.RightControl ) { continue; } // Check if the key was pressed bool pressed = Keyboard.GetState().IsKeyDown(key.Key); // If it was, decrement the countdown for that key if (pressed) { key.Countdown -= gameTime.ElapsedRealTime.Milliseconds; } if ((pressed) && (!key.Pressed)) // If it is pressed, but wasn't before... { // Set some flags and invoke the KeyDown event key.Pressed = true; keyEvent.Key = key.Key; if (KeyDown != null) { KeyDown.Invoke(keyEvent); } } else if ((!pressed) && (key.Pressed)) // If it isn't pressed, but was before... { // Set some flags, reset the countdown key.Pressed = false; key.Countdown = RepeatDelay; keyEvent.Key = key.Key; // Invoke the Key Up event if (KeyUp != null) { KeyUp.Invoke(keyEvent); } } // If the Key's Countdown has zeroed out, reset it, and make // sure that KeyDown fires again if (key.Countdown < 0) { keyEvent.Key = key.Key; if (KeyDown != null) { KeyDown.Invoke(keyEvent); } key.Countdown = RepeatRate; } } #endregion #region Update Mouse #if !XBOX MouseState mouseState = Mouse.GetState(); // Check for mouse move event if ((mouseState.X != this.currentMouseState.X) || (mouseState.Y != this.currentMouseState.Y)) { if (MouseMove != null) { MouseEventArgs mouseEvent = new MouseEventArgs(); mouseEvent.State = mouseState; mouseEvent.Button = MouseButtons.None; // Cap mouse position to the window boundaries mouseEvent.Position = new Point(mouseState.X, mouseState.Y); if (mouseEvent.Position.X < 0) { mouseEvent.Position.X = 0; } if (mouseEvent.Position.Y < 0) { mouseEvent.Position.Y = 0; } Rectangle bounds = this.Game.Window.ClientBounds; if (mouseEvent.Position.X > bounds.Width) { mouseEvent.Position.X = bounds.Width; } if (mouseEvent.Position.Y > bounds.Height) { mouseEvent.Position.Y = bounds.Height; } MouseMove.Invoke(mouseEvent); } } if (mouseState.LeftButton != currentMouseState.LeftButton) { if ((MouseUp != null) || (MouseDown != null)) { MouseEventArgs mouseEvent = new MouseEventArgs(); mouseEvent.State = mouseState; mouseEvent.Position = new Point(mouseState.X, mouseState.Y); mouseEvent.Button = MouseButtons.Left; if (mouseState.LeftButton == ButtonState.Released) { if (MouseUp != null) { MouseUp.Invoke(mouseEvent); } } else { if (MouseDown != null) { // Must request focus first, to prevent mousedown // event from being swallowed up if (RequestingFocus != null) { RequestingFocus.Invoke(mouseEvent); } MouseDown.Invoke(mouseEvent); } } } } if (mouseState.RightButton != currentMouseState.RightButton) { if ((MouseUp != null) || (MouseDown != null)) { MouseEventArgs mouseEvent = new MouseEventArgs(); mouseEvent.State = mouseState; mouseEvent.Position = new Point(mouseState.X, mouseState.Y); mouseEvent.Button = MouseButtons.Right; if (mouseState.RightButton == ButtonState.Released) { if (MouseUp != null) { MouseUp.Invoke(mouseEvent); } } else { if (MouseDown != null) { MouseDown.Invoke(mouseEvent); } } } } // Update mouse state this.currentMouseState = mouseState; #endif #endregion base.Update(gameTime); }
internal void OnMouseMove(Model model, MouseEventArgs e) => MouseMove?.Invoke(model, e);
private bool Handle(RawMouseMessages state, MouseState data) { bool prevented = false; IPoint coords = new Point(data.Point.X, data.Point.Y); int delta = data.WheelDelta; DateTime time = data.DateTime; switch (state) { case RawMouseMessages.Move: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Movement, coords, delta, MouseButtons.None, KeyState.None, false, time); InvokeOnEvent(this, eventArgs); MouseMove?.Invoke(this, eventArgs); prevented = eventArgs.DefaultPrevented; break; } case RawMouseMessages.LeftDown: { bool isDoubleClick = (data.Time - LastLeftClick) <= User32.DoubleClickTime; Interlocked.Exchange(ref LastLeftClick, data.Time - (isDoubleClick ? User32.DoubleClickTime + 1 : 0)); IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, MouseButtons.Left, KeyState.Down, isDoubleClick, time); InvokeOnEvent(this, eventArgs); MouseDown?.Invoke(this, eventArgs); MouseClick?.Invoke(this, eventArgs); if (isDoubleClick) { MouseDoubleClick?.Invoke(this, eventArgs); } prevented = eventArgs.DefaultPrevented; break; } case RawMouseMessages.MiddleDown: case RawMouseMessages.RightDown: { MouseButtons button = state == RawMouseMessages.RightDown ? MouseButtons.Right : MouseButtons.Middle; IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, button, KeyState.Down, false, time); InvokeOnEvent(this, eventArgs); MouseDown?.Invoke(this, eventArgs); MouseClick?.Invoke(this, eventArgs); prevented = eventArgs.DefaultPrevented; break; } case RawMouseMessages.LeftUp: case RawMouseMessages.MiddleUp: case RawMouseMessages.RightUp: { MouseButtons button = state == RawMouseMessages.LeftUp ? MouseButtons.Left : state == RawMouseMessages.MiddleUp ? MouseButtons.Middle : MouseButtons.Right; IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, button, KeyState.Up, false, time); InvokeOnEvent(this, eventArgs); MouseUp?.Invoke(this, eventArgs); prevented = eventArgs.DefaultPrevented; break; } case RawMouseMessages.Wheel: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Wheel, coords, delta, MouseButtons.Wheel, delta > 0 ? KeyState.Up : KeyState.Down, false, time); InvokeOnEvent(this, eventArgs); MouseWheel?.Invoke(this, eventArgs); prevented = eventArgs.DefaultPrevented; break; } case RawMouseMessages.HWheel: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.HorizontalWheel, coords, delta, MouseButtons.Wheel, delta > 0 ? KeyState.Up : KeyState.Down, false, time); InvokeOnEvent(this, eventArgs); MouseHorizontalWheel?.Invoke(this, eventArgs); prevented = eventArgs.DefaultPrevented; break; } default: break; } return(prevented); }
public virtual void DoMouseMove(MouseEventArgs e) { MouseMove?.Invoke(this, e); }
public void OnConversationFinish() { print("I just finished a conversation"); MouseMove.make_mouse_move(); ToggleCanvas.global.Hide(); }
/// <inheritdoc cref="MouseMove" /> private void ControlOnMouseMove(object sender, System.Windows.Forms.MouseEventArgs args) => MouseMove?.Invoke(sender, new MouseEventArgs(args));
private void mouseHook_Callback(int nCode, IntPtr wParam, IntPtr lParam, ref bool handled) { //Marshall the data from callback. MouseLLHookStruct mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct)); //detect button clicked MouseButtons button = MouseButtons.None; short mouseDelta = 0; bool mouseDown = false; bool mouseUp = false; switch ((int)wParam) { case WM_LBUTTONDOWN: mouseDown = true; button = MouseButtons.Left; break; case WM_LBUTTONUP: mouseUp = true; button = MouseButtons.Left; break; case WM_RBUTTONDOWN: mouseDown = true; button = MouseButtons.Right; break; case WM_RBUTTONUP: mouseUp = true; button = MouseButtons.Right; break; case WM_MBUTTONDOWN: mouseDown = true; button = MouseButtons.Middle; break; case WM_MBUTTONUP: mouseUp = true; button = MouseButtons.Middle; break; case WM_MOUSEWHEEL: //If the message is WM_MOUSEWHEEL, the high-order word of MouseData member is the wheel delta. //One wheel click is defined as WHEEL_DELTA, which is 120. //(value >> 16) & 0xffff; retrieves the high-order word from the given 32-bit value mouseDelta = (short)((mouseHookStruct.MouseData >> 16) & 0xffff); break; case WM_XBUTTONDOWN: mouseDown = true; switch (mouseHookStruct.MouseData >> 16) { case XBUTTON1: button = MouseButtons.XButton1; break; case XBUTTON2: button = MouseButtons.XButton2; break; } break; case WM_XBUTTONUP: mouseUp = true; switch (mouseHookStruct.MouseData >> 16) { case XBUTTON1: button = MouseButtons.XButton1; break; case XBUTTON2: button = MouseButtons.XButton2; break; } break; } //generate event MouseEventExtArgs e = new MouseEventExtArgs( button, mouseUp || mouseDown ? 1 : 0, mouseHookStruct.Point.X, mouseHookStruct.Point.Y, mouseDelta); //Mouse down if (MouseDown != null && mouseDown) { MouseDown.Invoke(null, e); } //If someone listens to click and a click is heppened if (MouseClick != null && mouseDown) { MouseClick.Invoke(null, e); } //Mouse up if (MouseUp != null && mouseUp) { MouseUp.Invoke(null, e); } //Wheel was moved if (MouseWheel != null && mouseDelta != 0) { MouseWheel.Invoke(null, e); } handled = handled || e.Handled; //If someone listens to move and there was a change in coordinates raise move event if ((MouseMove != null) && (mOldX != mouseHookStruct.Point.X || mOldY != mouseHookStruct.Point.Y)) { mOldX = mouseHookStruct.Point.X; mOldY = mouseHookStruct.Point.Y; MouseMove.Invoke(null, e); handled = handled || (e.Handled && (int)wParam == WM_MOUSEMOVE); } }
protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, MouseMove Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, MouseMove, Data, RawData, Timestamp);
private void Listbox_MouseMove(object sender, MouseEventArgs e) { MouseMove?.Invoke(this, e); }
internal void InvokeMouseMove(ScreenEventArgs args) => MouseMove?.Invoke(this, args);
protected virtual void OnMouseMove(Vector2 position) => MouseMove?.Invoke(position);
protected virtual void OnMouseMove(GameTime g, MouseState m) => MouseMove?.Invoke(this, g, m);
protected override bool HookCallback(IntPtr wParam, IntPtr lParam) { var mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct)); MouseButtons button = MouseButtons.None; Keys keyCode = Keys.None; short mouseDelta = 0; int clickCount = 0; bool isMouseButtonDown = false; bool isMouseButtonUp = false; switch ((Messages)wParam) { case Messages.WM_LBUTTONDOWN: case Messages.WM_LBUTTONUP: case Messages.WM_LBUTTONDBLCLK: button = MouseButtons.Left; keyCode = Keys.LButton; break; case Messages.WM_RBUTTONDOWN: case Messages.WM_RBUTTONUP: case Messages.WM_RBUTTONDBLCLK: button = MouseButtons.Right; keyCode = Keys.RButton; break; case Messages.WM_MBUTTONDOWN: case Messages.WM_MBUTTONUP: case Messages.WM_MBUTTONDBLCLK: button = MouseButtons.Middle; keyCode = Keys.MButton; break; case Messages.WM_XBUTTONDOWN: case Messages.WM_XBUTTONUP: case Messages.WM_XBUTTONDBLCLK: if (mouseHookStruct.MouseData == 1) { button = MouseButtons.XButton1; keyCode = Keys.XButton1; } else { button = MouseButtons.XButton2; keyCode = Keys.XButton2; } break; } switch ((Messages)wParam) { case Messages.WM_MOUSEWHEEL: mouseDelta = mouseHookStruct.MouseData; if (mouseDelta > 0) { keyCode = (Keys)KeysEx.WheelUp; } if (mouseDelta < 0) { keyCode = (Keys)KeysEx.WheelDown; } break; case Messages.WM_MOUSEHWHEEL: //mouseDelta = mouseHookStruct.MouseData; break; case Messages.WM_LBUTTONDOWN: case Messages.WM_RBUTTONDOWN: case Messages.WM_MBUTTONDOWN: case Messages.WM_XBUTTONDOWN: clickCount = 1; isMouseButtonDown = true; break; case Messages.WM_LBUTTONUP: case Messages.WM_RBUTTONUP: case Messages.WM_MBUTTONUP: case Messages.WM_XBUTTONUP: clickCount = 1; isMouseButtonUp = true; break; case Messages.WM_LBUTTONDBLCLK: case Messages.WM_RBUTTONDBLCLK: case Messages.WM_MBUTTONDBLCLK: case Messages.WM_XBUTTONDBLCLK: clickCount = 2; break; } var e = new MouseEventExtArgs( button, keyCode, clickCount, mouseHookStruct.Point.X, mouseHookStruct.Point.Y, mouseDelta); if (MouseDown != null && isMouseButtonDown) { MouseDown.Invoke(null, e); } if (MouseUp != null && isMouseButtonUp) { MouseUp.Invoke(null, e); } if (MouseWheel != null && mouseDelta != 0) { MouseWheel.Invoke(null, e); } if (MouseMove != null && !_oldPoint.Equals(mouseHookStruct.Point)) { MouseMove.Invoke(null, e); } _oldPoint = mouseHookStruct.Point; return(e.Handled); }
void Awake() { controller = new Controller(); hndCheck = (FistCheck)GetComponent<FistCheck>(); trnCheck = (TurnWorld)GetComponent<TurnWorld>(); //rszCheck = (Resize)GetComponent<Resize>(); MsCheck = (MouseMove)GetComponent<MouseMove>(); }