personal_training_martial_arts.Core.Button.updateState C# (CSharp) Method

updateState() public method

public updateState ( ) : BState
return BState
        public BState updateState()
        {
            MouseState mouse_state = Mouse.GetState();
            int mx = mouse_state.X;
            int my = mouse_state.Y;
            prev_mpressed = mpressed;
            mpressed = mouse_state.LeftButton == ButtonState.Pressed;

            // raton encima del boton
            if(hit_button(this.rectangle, mx, my))
            {
                // si se esta presionando el boton
                if (mpressed)
                {
                    state = BState.DOWN;
                }
                // si ha habido un click y el boton estaba pulsado
                else if (!mpressed && prev_mpressed)
                {
                    if (state == BState.DOWN)
                    {
                        state = BState.JUST_RELEASED;
                    }
                }
                // si el raton esta encima del boton
                else
                {
                    state = BState.HOVER;
                }
            }
            // si el raton no esta sobre el boton
            else
            {
                state = BState.UP;
            }

            return state;
        }