public Button(Vector2f position, string value)
{
Size = new Vector2f(Width, Height);
Position = position - Size / 2.0f;
Visible = true;
this.value = value;
mouseIn = false;
myState = Game.PeekState();
Input.MouseMove = args =>
{
mouseIn = BoundingBox.Contains(args.Position.X, args.Position.Y);
return mouseIn;
};
Input.MouseButton[Mouse.Button.Left] = args =>
{
if (!mouseIn || !args.Pressed || !Clickable)
return false;
if (OnClick != null && OnClick())
Assets.PlaySound("Click.wav");
return true;
};
// Simulate mouse move
Vector2i mousePosition = Mouse.GetPosition(Game.Window);
Input.MouseMove(new MouseMoveInputArgs(mousePosition.X, mousePosition.Y));
}