mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Replaced clickLeft with clickPressed clickReleased methods
This commit is contained in:
@@ -167,39 +167,48 @@ void CButton::onButtonClicked()
|
||||
callback();
|
||||
}
|
||||
|
||||
void CButton::clickLeft(tribool down, bool previousState)
|
||||
void CButton::clickPressed(const Point & cursorPosition)
|
||||
{
|
||||
if(isBlocked())
|
||||
return;
|
||||
|
||||
if (down)
|
||||
if (getState() != PRESSED)
|
||||
{
|
||||
if (getState() != PRESSED)
|
||||
{
|
||||
if (!soundDisabled)
|
||||
CCS->soundh->playSound(soundBase::button);
|
||||
setState(PRESSED);
|
||||
if (!soundDisabled)
|
||||
CCS->soundh->playSound(soundBase::button);
|
||||
setState(PRESSED);
|
||||
|
||||
if (actOnDown)
|
||||
onButtonClicked();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getState() == PRESSED)
|
||||
{
|
||||
if(hoverable && isHovered())
|
||||
setState(HIGHLIGHTED);
|
||||
else
|
||||
setState(NORMAL);
|
||||
|
||||
if (!actOnDown && previousState && (down == false))
|
||||
onButtonClicked();
|
||||
}
|
||||
if (actOnDown)
|
||||
onButtonClicked();
|
||||
}
|
||||
}
|
||||
|
||||
void CButton::showPopupWindow()
|
||||
void CButton::clickReleased(const Point & cursorPosition)
|
||||
{
|
||||
if (getState() == PRESSED)
|
||||
{
|
||||
if(hoverable && isHovered())
|
||||
setState(HIGHLIGHTED);
|
||||
else
|
||||
setState(NORMAL);
|
||||
|
||||
if (!actOnDown)
|
||||
onButtonClicked();
|
||||
}
|
||||
}
|
||||
|
||||
void CButton::clickCancel(const Point & cursorPosition)
|
||||
{
|
||||
if (getState() == PRESSED)
|
||||
{
|
||||
if(hoverable && isHovered())
|
||||
setState(HIGHLIGHTED);
|
||||
else
|
||||
setState(NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void CButton::showPopupWindow(const Point & cursorPosition)
|
||||
{
|
||||
if(helpBox.size()) //there is no point to show window with nothing inside...
|
||||
CRClickPopup::createAndPush(helpBox);
|
||||
@@ -377,7 +386,7 @@ void CToggleButton::setEnabled(bool enabled)
|
||||
setState(enabled ? NORMAL : BLOCKED);
|
||||
}
|
||||
|
||||
void CToggleButton::clickLeft(tribool down, bool previousState)
|
||||
void CToggleButton::clickPressed(const Point & cursorPosition)
|
||||
{
|
||||
// force refresh
|
||||
hover(false);
|
||||
@@ -386,22 +395,41 @@ void CToggleButton::clickLeft(tribool down, bool previousState)
|
||||
if(isBlocked())
|
||||
return;
|
||||
|
||||
if (down && canActivate())
|
||||
if (canActivate())
|
||||
{
|
||||
CCS->soundh->playSound(soundBase::button);
|
||||
setState(PRESSED);
|
||||
}
|
||||
}
|
||||
|
||||
if(previousState)//mouse up
|
||||
void CToggleButton::clickReleased(const Point & cursorPosition)
|
||||
{
|
||||
// force refresh
|
||||
hover(false);
|
||||
hover(true);
|
||||
|
||||
if(isBlocked())
|
||||
return;
|
||||
|
||||
if (getState() == PRESSED && canActivate())
|
||||
{
|
||||
if(down == false && getState() == PRESSED && canActivate())
|
||||
{
|
||||
onButtonClicked();
|
||||
setSelected(!selected);
|
||||
}
|
||||
else
|
||||
doSelect(selected); // restore
|
||||
onButtonClicked();
|
||||
setSelected(!selected);
|
||||
}
|
||||
else
|
||||
doSelect(selected); // restore
|
||||
}
|
||||
|
||||
void CToggleButton::clickCancel(const Point & cursorPosition)
|
||||
{
|
||||
// force refresh
|
||||
hover(false);
|
||||
hover(true);
|
||||
|
||||
if(isBlocked())
|
||||
return;
|
||||
|
||||
doSelect(selected);
|
||||
}
|
||||
|
||||
void CToggleGroup::addCallback(std::function<void(int)> callback)
|
||||
|
||||
Reference in New Issue
Block a user