summaryrefslogtreecommitdiff
path: root/plugingui/button_base.cc
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui/button_base.cc')
-rw-r--r--plugingui/button_base.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/plugingui/button_base.cc b/plugingui/button_base.cc
index 1030bbc..bf441f5 100644
--- a/plugingui/button_base.cc
+++ b/plugingui/button_base.cc
@@ -42,7 +42,7 @@ ButtonBase::~ButtonBase()
void ButtonBase::buttonEvent(ButtonEvent* buttonEvent)
{
// Ignore everything except left clicks.
- if(buttonEvent->button != MouseButton::left)
+ if(!enabled || buttonEvent->button != MouseButton::left)
{
return;
}
@@ -74,8 +74,23 @@ void ButtonBase::setText(const std::string& text)
redraw();
}
+void ButtonBase::setEnabled(bool enabled)
+{
+ this->enabled = enabled;
+ redraw();
+}
+
+bool ButtonBase::isEnabled() const
+{
+ return enabled;
+}
+
void ButtonBase::mouseLeaveEvent()
{
+ if (!enabled) {
+ return;
+ }
+
in_button = false;
if(button_state == State::Down)
{
@@ -86,6 +101,10 @@ void ButtonBase::mouseLeaveEvent()
void ButtonBase::mouseEnterEvent()
{
+ if (!enabled) {
+ return;
+ }
+
in_button = true;
if(button_state == State::Down)
{