Exemplo n.º 1
0
        public void Update(RenderWindow Window)
        {
            if (!_WheelMoved)
            {
                _WheelDelta = 0;
            }
            _WheelMoved = false;

            if (_Changes.First != null)
            {
                _Changes.First.Acknowledge(_Changes.Second, _Changes.Third);
                _Changes.First = null;
            }

            _Position = Window.MapPixelToCoords(Mouse.GetPosition(Window), Window.GetView());
            bool on = true;

            if (Position.X < 0 || Position.Y < 0 || Position.Y > Window.Size.Y || Position.X > Window.Size.X)
            {
                on = false;
            }

            if (_LeftDrag && on)
            {
                _DragDelta = _Position - _DragStart;
                _DragStart = _Position;
            }
            else if (on)
            {
                _DragDelta = _Position - _DragStart;
                if (_LeftDown && Math.Abs(_DragDelta.X) + Math.Abs(_DragDelta.Y) >= 1)
                {
                    _LeftDrag  = true;
                    _DragStart = Position;
                }
            }
            else
            {
                _DragDelta = new Vector2f(0, 0);
            }

            if (!_LeftUp && !Mouse.IsButtonPressed(Mouse.Button.Left) &&
                OnLeftUp != null)
            {
                OnLeftUp(this, new MouseEventArgs(_Position));
            }
            else if (!_LeftDown && Mouse.IsButtonPressed(Mouse.Button.Left) &&
                     OnLeftDown != null)
            {
                OnLeftDown(this, new MouseEventArgs(_Position));
            }

            _LeftUp    = !Mouse.IsButtonPressed(Mouse.Button.Left);
            _LeftClick = _LeftUp && _LeftDown && !_LeftDrag;

            if (_LeftClick && OnLeftClick != null)
            {
                OnLeftClick(this, new MouseEventArgs(_Position));
            }

            _DragStart = _Position;
            _LeftDown  = !_LeftUp;
            if (_LeftUp)
            {
                _LeftDrag  = false;
                _DragDelta = new Vector2f(0, 0);
            }

            _RightUp    = !Mouse.IsButtonPressed(Mouse.Button.Right);
            _RightClick = _RightUp && _RightDown;
            _RightDown  = !_RightUp;

            _LastTop = _Top;
        }
Exemplo n.º 2
0
 internal void Put(Interactive Mouseable)
 {
     _Top = Mouseable;
 }