private void OnLostMouseCapture(object sender, EventArgs args) { var buttonsToRelease = DownButtons.ToArray(); foreach (var button in buttonsToRelease) { MouseState.HandleButtonUp(button); } }
static internal void Update() { keyboardPrev = keyboard; mousePrev = mouse; mousePosPrev = mousePos; prevDownKeys = DownKeys.ToArray(); prevDownButtons = DownButtons.ToArray(); keyboard = Keyboard.GetState(); mouse = Mouse.GetState(); if (AcceptMouse) { mousePos = new Vector2(Cursor.Position.X - MMW.X, Cursor.Position.Y - MMW.Y); } DownKeys = GetDownKeys(); { var list = new List <Key>(); foreach (var k in DownKeys) { if (!prevDownKeys.Contains(k)) { list.Add(k); } } PressedKeys = list.ToArray(); } { var list = new List <Key>(); foreach (var k in prevDownKeys) { if (!DownKeys.Contains(k)) { list.Add(k); } } ReleasedKeys = list.ToArray(); } DownButtons = GetDownButtons(); { var list = new List <MouseButton>(); foreach (var b in DownButtons) { if (!prevDownButtons.Contains(b)) { list.Add(b); } } PressedButtons = list.ToArray(); } { var list = new List <MouseButton>(); foreach (var b in prevDownButtons) { if (!DownButtons.Contains(b)) { list.Add(b); } } ReleasedButtons = list.ToArray(); } }