mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
allow double click for bonus selection
This commit is contained in:
@@ -446,10 +446,13 @@ void CToggleBase::setAllowDeselection(bool on)
|
||||
}
|
||||
|
||||
CToggleButton::CToggleButton(Point position, const AnimationPath &defName, const std::pair<std::string, std::string> &help,
|
||||
CFunctionList<void(bool)> callback, EShortcut key, bool playerColoredButton):
|
||||
CFunctionList<void(bool)> callback, EShortcut key, bool playerColoredButton,
|
||||
CFunctionList<void()> callbackSelected):
|
||||
CButton(position, defName, help, 0, key, playerColoredButton),
|
||||
CToggleBase(callback)
|
||||
CToggleBase(callback),
|
||||
callbackSelected(callbackSelected)
|
||||
{
|
||||
addUsedEvents(DOUBLECLICK);
|
||||
}
|
||||
|
||||
void CToggleButton::doSelect(bool on)
|
||||
@@ -516,6 +519,12 @@ void CToggleButton::clickCancel(const Point & cursorPosition)
|
||||
doSelect(isSelected());
|
||||
}
|
||||
|
||||
void CToggleButton::clickDouble(const Point & cursorPosition)
|
||||
{
|
||||
if(callbackSelected)
|
||||
callbackSelected();
|
||||
}
|
||||
|
||||
void CToggleGroup::addCallback(const std::function<void(int)> & callback)
|
||||
{
|
||||
onChange += callback;
|
||||
|
||||
@@ -166,13 +166,17 @@ class CToggleButton : public CButton, public CToggleBase
|
||||
void doSelect(bool on) override;
|
||||
void setEnabled(bool enabled) override;
|
||||
|
||||
CFunctionList<void()> callbackSelected;
|
||||
|
||||
public:
|
||||
CToggleButton(Point position, const AnimationPath &defName, const std::pair<std::string, std::string> &help,
|
||||
CFunctionList<void(bool)> Callback = 0, EShortcut key = {}, bool playerColoredButton = false );
|
||||
CFunctionList<void(bool)> Callback = nullptr, EShortcut key = {}, bool playerColoredButton = false,
|
||||
CFunctionList<void()> CallbackSelected = nullptr );
|
||||
|
||||
void clickPressed(const Point & cursorPosition) override;
|
||||
void clickReleased(const Point & cursorPosition) override;
|
||||
void clickCancel(const Point & cursorPosition) override;
|
||||
void clickDouble(const Point & cursorPosition) override;
|
||||
|
||||
// bring overrides into scope
|
||||
//using CButton::addCallback;
|
||||
|
||||
Reference in New Issue
Block a user