예제 #1
0
        public override void HandleInput(InputHandler input)
        {
            base.HandleInput(input);

            bool oldActive = Active;

            if (input.CurrentMouseState.LeftButton == ButtonState.Released)
            {
                Active = false;
            }

            if(rectangle.Contains(input.CurrentMouseState.X, input.CurrentMouseState.Y))
            {
                if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
                {
                    Active = true;
                }

                if(input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed && oldActive)
                {
                    if (OnClick != null)
                    {
                        OnClick(this, null);
                        Active = false;
                    }
                }
            }
        }
예제 #2
0
 public virtual void HandleInput(InputHandler input)
 {
     if (!Enabled)
     {
         Active = false;
         return;
     }
 }
예제 #3
0
        public override void HandleInput(InputHandler input)
        {
            base.HandleInput(input);

            if(input.CurrentMouseState.LeftButton == ButtonState.Released)
            {
                Active = false;
            }

            if (Rectangle.Contains(input.CurrentMouseState.X, input.CurrentMouseState.Y))
            {
                if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
                {
                    Active = true;
                }
            }

            if (Active)
            {
                float oldValue = Value;
                float temp = (input.CurrentMouseState.X - _position.X - handleWidth * 0.5f) / (Length - handleWidth) * (Max - Min) + Min;
                Value = (float)Math.Round(MathHelper.Clamp(temp, Min, Max), Precision);

                if (oldValue != Value)
                {
                    if (OnValueChanged != null)
                    {
                        OnValueChanged(this, null);
                    }
                }
            }
        }
        public void HandleInput(InputHandler inputHandler)
        {
            if (DisplayDebug)
            {
                guiElements.HandleInput(inputHandler);
            }

            if (inputHandler.IsKeyPressed(Keys.LeftShift))
            {
                drawUsingMarchingCubes = !drawUsingMarchingCubes;
            }

            if (inputHandler.IsKeyPressed(Keys.F1))
            {
                DisplayDebug = !DisplayDebug;
            }

            if (inputHandler.IsKeyPressed(Keys.Tab))
            {
                debugGrid.Visible = !debugGrid.Visible;
            }
        }