Example #1
0
 private void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && _state == InteractableState.Down)
     {
         if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
         {
             _state = InteractableState.Hover;
             Released?.Invoke(this, EventArgs.Empty);
         }
         else
         {
             _state = InteractableState.Normal;
             ReleasedOutside?.Invoke(this, EventArgs.Empty);
         }
     }
 }
Example #2
0
 private void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && _state == InteractableState.Down)
     {
         if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
         {
             /*bool update = false;
              * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
              *      update = true;
              * }*/
             Texture = (_hoverTexture != null) ? atlas.GetTexture(_hoverTexture) : atlas.GetTexture(_normalTexture);
             //if (update) {
             _hitBox.X      = 0.0d;
             _hitBox.Y      = 0.0d;
             _hitBox.Width  = Width;
             _hitBox.Height = Height;
             //}
             _state = InteractableState.Hover;
             Released?.Invoke(this, EventArgs.Empty);
         }
         else
         {
             /*bool update = false;
              * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
              *      update = true;
              * }*/
             Texture = atlas.GetTexture(_normalTexture);
             //if (update) {
             _hitBox.X      = 0.0d;
             _hitBox.Y      = 0.0d;
             _hitBox.Width  = Width;
             _hitBox.Height = Height;
             //}
             _state = InteractableState.Normal;
             ReleasedOutside?.Invoke(this, EventArgs.Empty);
         }
     }
 }