public void OnMouseUp(CCEventMouse eventMouse, CCNode container) { OnInterfaceButtonUp( eventMouse.CursorX, eventMouse.CursorY, eventMouse.MouseButton == CCMouseButton.LeftButton, eventMouse.MouseButton == CCMouseButton.RightButton, eventMouse.MouseButton == CCMouseButton.MiddleButton, container ); }
void AddIncomingScrollMouse(int id, ref CCPoint position, float wheelDelta) { lock (mouseLock) { if (!mouseMap.ContainsKey(id)) { var mouse = new CCEventMouse(CCMouseEventType.MOUSE_SCROLL, id, position, gameTime.ElapsedGameTime); mouse.ScrollY += wheelDelta; incomingScrollMouse.Add(mouse); mouseMap.Add(id, mouse); } } }
void AddIncomingMouse(int id, ref CCPoint position, CCMouseButton buttons = CCMouseButton.None) { lock (mouseLock) { if (!mouseMap.ContainsKey(id)) { var mouse = new CCEventMouse(((buttons == CCMouseButton.None) ? CCMouseEventType.MOUSE_MOVE : CCMouseEventType.MOUSE_DOWN), id, position, gameTime.ElapsedGameTime); mouse.MouseButton = buttons; incomingNewMouse.Add(mouse); mouseMap.Add(id, mouse); } } }
public void OnMouseDown(CCEventMouse eventMouse, CCNode container) { OnInterfaceButtonDown( eventMouse.CursorX, eventMouse.CursorY, eventMouse.MouseButton == CCMouseButton.LeftButton, eventMouse.MouseButton == CCMouseButton.RightButton, eventMouse.MouseButton == CCMouseButton.MiddleButton, container ); if (rightclick) { OnInterfaceDragStart(container); } }
void OnMouseMove(CCEventMouse mouseEvent) { mousePosition.Text = "Mouse Position: X: " + mouseEvent.CursorX + " Y: " + mouseEvent.CursorY; }
void OnMouseScroll(CCEventMouse mouseEvent) { scrollWheel.Text = "Scroll Wheel Delta: X: " + mouseEvent.ScrollX + " Y: " + mouseEvent.ScrollY; }
void OnMouseDown(CCEventMouse mouseEvent) { mouseButtonDown.Text = "Mouse Button Down: " + mouseEvent.MouseButton; }
void OnMouseUp(CCEventMouse mouseEvent) { mouseButtonUp.Text = "Mouse Button Up: " + mouseEvent.MouseButton; }
void ProcessMouse(CCWindow window) { // Read the current Mouse state MouseState currentMouseState = Mouse.GetState(); var dispatcher = window.EventDispatcher; if (currentMouseState == priorMouseState || !dispatcher.IsEventListenersFor(CCEventListenerMouse.LISTENER_ID)) { priorMouseState = currentMouseState; return; } CCPoint pos; #if NETFX_CORE //Because MonoGame and CocosSharp uses different Y axis, we need to convert the coordinate here pos = TransformPoint(priorMouseState.X, Game.Window.ClientBounds.Height - priorMouseState.Y); #else //Because MonoGame and CocosSharp uses different Y axis, we need to convert the coordinate here //No need to convert Y-Axis pos = new CCPoint(priorMouseState.X, priorMouseState.Y); #endif var mouseEvent = new CCEventMouse(CCMouseEventType.MOUSE_MOVE); mouseEvent.CursorX = pos.X; mouseEvent.CursorY = pos.Y; dispatcher.DispatchEvent(mouseEvent); CCMouseButton mouseButton = CCMouseButton.None; if (priorMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.LeftButton; } if (priorMouseState.RightButton == ButtonState.Released && currentMouseState.RightButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.RightButton; } if (priorMouseState.MiddleButton == ButtonState.Released && currentMouseState.MiddleButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.MiddleButton; } if (priorMouseState.XButton1 == ButtonState.Released && currentMouseState.XButton1 == ButtonState.Pressed) { mouseButton |= CCMouseButton.ExtraButton1; } if (priorMouseState.XButton2 == ButtonState.Released && currentMouseState.XButton2 == ButtonState.Pressed) { mouseButton |= CCMouseButton.ExtraButton1; } if (mouseButton > 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_DOWN; mouseEvent.MouseButton = mouseButton; dispatcher.DispatchEvent(mouseEvent); } mouseButton = CCMouseButton.None; if (priorMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released) { mouseButton |= CCMouseButton.LeftButton; } if (priorMouseState.RightButton == ButtonState.Pressed && currentMouseState.RightButton == ButtonState.Released) { mouseButton |= CCMouseButton.RightButton; } if (priorMouseState.MiddleButton == ButtonState.Pressed && currentMouseState.MiddleButton == ButtonState.Released) { mouseButton |= CCMouseButton.MiddleButton; } if (priorMouseState.XButton1 == ButtonState.Pressed && currentMouseState.XButton1 == ButtonState.Released) { mouseButton |= CCMouseButton.ExtraButton1; } if (priorMouseState.XButton2 == ButtonState.Pressed && currentMouseState.XButton2 == ButtonState.Released) { mouseButton |= CCMouseButton.ExtraButton1; } if (mouseButton > 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_UP; mouseEvent.MouseButton = mouseButton; dispatcher.DispatchEvent(mouseEvent); } if (priorMouseState.ScrollWheelValue != currentMouseState.ScrollWheelValue) { var delta = priorMouseState.ScrollWheelValue - currentMouseState.ScrollWheelValue; if (delta != 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_SCROLL; mouseEvent.ScrollX = 0; mouseEvent.ScrollY = delta; dispatcher.DispatchEvent(mouseEvent); //Console.WriteLine ("mouse scroll: " + mouseEvent.ScrollY); } } // Store the state for the next loop priorMouseState = currentMouseState; }
private void OnMouseScroll(CCEventMouse e) { /** get scale coef.*/ float windowScaleX = Window.WindowSizeInPixels.Width/Settings.ScreenWidth; float windowScaleY = Window.WindowSizeInPixels.Height/Settings.ScreenHeight; /** Актуальные координаты */ _mousePosX = (int) (e.CursorX/windowScaleX); _mousePosY = (int) (e.CursorY/windowScaleY); }
private void OnMouseDown(CCEventMouse e) { Input.OnMousePress(e.MouseButton); }
public void OnMouseMove(CCEventMouse mouseState, CCNode container) { OnMouseDown(mouseState, container); OnInterfaceDragMove(mouseState.CursorX, mouseState.CursorY, container); }
public virtual void OnMouseScroll(CCEventMouse mouseEvent) { }
void OnMouseScroll(CCEventMouse mouseEvent) { // Due to a bug in MonoGame the menu will jump around on Mac when hitting the top element // https://github.com/mono/MonoGame/issues/2276 var delta = mouseEvent.ScrollY; CCRect visibleBounds = Layer.VisibleBoundsWorldspace; curPos = testListMenu.Position; var nextPos = curPos; nextPos.Y -= (delta) / LINE_SPACE; if (nextPos.Y < 0) { testListMenu.Position = CCPoint.Zero; return; } if (nextPos.Y > (((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE - visibleBounds.Size.Height)) { testListMenu.Position = (new CCPoint(0, (((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE - visibleBounds.Size.Height))); return; } testListMenu.Position = nextPos; curPos = nextPos; }
private void OnMouseUp(CCEventMouse e) { Input.OnMouseRelease(e.MouseButton); }
public override void OnMouseScroll(CCEventMouse mouseEvent) { base.OnMouseScroll(mouseEvent); if (mouseEvent.ScrollY < 0) ZoomIn(); if (mouseEvent.ScrollY > 0) ZoomOut(); }
void ProcessMouse(CCWindow window) { // Read the current Mouse state MouseState currentMouseState = Mouse.GetState(); var dispatcher = window.EventDispatcher; if (currentMouseState == priorMouseState || !dispatcher.IsEventListenersFor(CCEventListenerMouse.LISTENER_ID)) { priorMouseState = currentMouseState; return; } CCPoint pos; #if NETFX_CORE //Because MonoGame and CocosSharp uses different Y axis, we need to convert the coordinate here pos = TransformPoint(priorMouseState.X, Game.Window.ClientBounds.Height - priorMouseState.Y); #else //Because MonoGame and CocosSharp uses different Y axis, we need to convert the coordinate here pos = new CCPoint(priorMouseState.X, Game.Window.ClientBounds.Height - priorMouseState.Y); #endif var mouseEvent = new CCEventMouse(CCMouseEventType.MOUSE_MOVE); mouseEvent.CursorX = pos.X; mouseEvent.CursorY = pos.Y; dispatcher.DispatchEvent(mouseEvent); CCMouseButton mouseButton = CCMouseButton.None; if (priorMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.LeftButton; } if (priorMouseState.RightButton == ButtonState.Released && currentMouseState.RightButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.RightButton; } if (priorMouseState.MiddleButton == ButtonState.Released && currentMouseState.MiddleButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.MiddleButton; } if (priorMouseState.XButton1 == ButtonState.Released && currentMouseState.XButton1 == ButtonState.Pressed) { mouseButton |= CCMouseButton.ExtraButton1; } if (priorMouseState.XButton2 == ButtonState.Released && currentMouseState.XButton2 == ButtonState.Pressed) { mouseButton |= CCMouseButton.ExtraButton1; } if (mouseButton > 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_DOWN; mouseEvent.MouseButton = mouseButton; dispatcher.DispatchEvent(mouseEvent); } mouseButton = CCMouseButton.None; if (priorMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released) { mouseButton |= CCMouseButton.LeftButton; } if (priorMouseState.RightButton == ButtonState.Pressed && currentMouseState.RightButton == ButtonState.Released) { mouseButton |= CCMouseButton.RightButton; } if (priorMouseState.MiddleButton == ButtonState.Pressed && currentMouseState.MiddleButton == ButtonState.Released) { mouseButton |= CCMouseButton.MiddleButton; } if (priorMouseState.XButton1 == ButtonState.Pressed && currentMouseState.XButton1 == ButtonState.Released) { mouseButton |= CCMouseButton.ExtraButton1; } if (priorMouseState.XButton2 == ButtonState.Pressed && currentMouseState.XButton2 == ButtonState.Released) { mouseButton |= CCMouseButton.ExtraButton1; } if (mouseButton > 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_UP; mouseEvent.MouseButton = mouseButton; dispatcher.DispatchEvent(mouseEvent); } if (priorMouseState.ScrollWheelValue != currentMouseState.ScrollWheelValue) { var delta = priorMouseState.ScrollWheelValue - currentMouseState.ScrollWheelValue; if (delta != 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_SCROLL; mouseEvent.ScrollX = 0; mouseEvent.ScrollY = delta; dispatcher.DispatchEvent(mouseEvent); //Console.WriteLine ("mouse scroll: " + mouseEvent.ScrollY); } } // Store the state for the next loop priorMouseState = currentMouseState; }