Exemple #1
0
        public override void HandleInput(InputState inputState, bool isTopMost, ScreenManager screenManager)
        {
            hovering = inputState.IsMouseInRectangle(thumbRectangle);

            // 单击
            if (inputState.IsMouseLeftButtonPressed(Bounds) || inputState.IsNewMouseLeftButtonReleased(Bounds))
            {
                if (MoveThumbTo(new Point(inputState.CurrentMouseState.X, inputState.CurrentMouseState.Y)))
                    if (OnDrag != null)
                        OnDrag(this);
            }

            base.HandleInput(inputState, isTopMost, screenManager);
        }
Exemple #2
0
        public override void HandleInput(InputState inputState, bool isTopMost, ScreenManager screenManager)
        {
            if (!Enabled)
            {
                currentState = "disabled";
                return;
            }

            if (inputState.IsMouseInRectangle(Bounds))
            {
                //2-按下,1-经过
                currentState = inputState.IsMouseLeftButtonPressed(Bounds) ? "pressed" : "hover";

                //松开按键时立刻引发事件
                if (inputState.IsNewMouseLeftButtonReleased(Bounds))
                {
                    if (OnClick != null) OnClick(this);
                }
            }
            else
            {
                //通常
                currentState = "normal";
            }

            base.HandleInput(inputState, isTopMost, screenManager);
        }