/// <summary> /// Adds the clickable to the menu, and adds height to it. /// </summary> /// <param name="clickable"></param> public override void add(Clickable clickable) { height += clickable.getHeight() + 2; if (clickable.getWidth() > width) width = clickable.getWidth(); base.add(clickable); }
/// <summary> /// Checks if the right mouse button is pressing the clickable. /// </summary> /// <param name="clickable"></param> /// <returns></returns> public bool isRightPressing(Clickable clickable) { if (Mouse.GetState().RightButton.Equals(ButtonState.Pressed)) { if (Mouse.GetState().X >= clickable.getVector().X && Mouse.GetState().X <= clickable.getVector().X + clickable.getWidth()) { if (Mouse.GetState().Y >= clickable.getVector().Y && Mouse.GetState().Y <= clickable.getVector().Y + clickable.getHeight()) { return true; } } } return false; }
/// <summary> /// Checks if the clickable is being pressed. /// </summary> /// <param name="clickable"></param> /// <returns></returns> public bool isPressing(Clickable clickable) { bool set = (clicked == clickable); if (clicked != null) { if (clicked.getLayer() < clickable.getLayer()) return false; if (laps++ > 25) { if (!set) if (!isPressing(clicked)) { clicked.tellPressed(false); clicked = null; } laps = 0; } } bool pressed = Mouse.GetState().LeftButton.Equals(ButtonState.Pressed); if (clicked == null || set) if (pressed) { if (set) { return true; } if (Mouse.GetState().X >= clickable.getVector().X && Mouse.GetState().X <= clickable.getVector().X + clickable.getWidth()) { if (Mouse.GetState().Y >= clickable.getVector().Y && Mouse.GetState().Y <= clickable.getVector().Y + clickable.getHeight()) { clicked = clickable; clicked.tellPressed(true); return true; } } } //temp fix if (set && textBoxFocused()) { if (Mouse.GetState().X >= clickable.getVector().X && Mouse.GetState().X <= clickable.getVector().X + clickable.getWidth()) { if (Mouse.GetState().Y >= clickable.getVector().Y && Mouse.GetState().Y <= clickable.getVector().Y + clickable.getHeight()) { clicked = clickable; clicked.tellPressed(true); return true; } } } clickable.tellPressed(false); return false; }