コード例 #1
0
void PromptButton::Update(int delta)
{
    if (isEnabled)
    {
        isClicked = false;
        isMouseDown = false;
        isMouseOver = false;

        RectangleWH positionRect = RectangleWH(position.GetX(), position.GetY(), pTextFont->GetWidth(text), pTextFont->GetHeight(text));
        bool isPressed = MouseHelper::PressedAndHeldAnywhere() || MouseHelper::DoublePressedAndHeldAnywhere();

        if (MouseHelper::ClickedOnRect(positionRect))
        {
            playSound(GetClickSoundEffect());
            isClicked = true;
            return;
        }

        if (MouseHelper::MouseDownOnRect(positionRect) && !isPressed)
        {
            isMouseDown = true;
        }
        else if (MouseHelper::MouseOverRect(positionRect) && !isPressed)
        {
            isMouseOver = true;
        }
    }
}
コード例 #2
0
void Button::OnClicked()
{
    EventProviders::GetButtonEventProvider()->RaiseButtonClicked(this, id);
    playSound(GetClickSoundEffect());
}