Make buttons toggleable by single clicking
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "../Scene.h"
|
||||
#include "../Logic.h"
|
||||
#include "../Connector.h"
|
||||
|
||||
#include "ToggleButton.h"
|
||||
#include "LightBulb.h"
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ QPainterPath ToggleButton::symbolPainterPath(QRect limits)
|
||||
return QPainterPath();
|
||||
}
|
||||
|
||||
void ToggleButton::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
void ToggleButton::partClickedEvent()
|
||||
{
|
||||
m_toggleState = !m_toggleState;
|
||||
if(m_toggleState)
|
||||
@@ -41,5 +41,4 @@ void ToggleButton::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
m_brushColorSelected = Qt::GlobalColor::red;
|
||||
}
|
||||
update();
|
||||
Part::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@ public:
|
||||
QPainterPath symbolPainterPath(QRect limits) override;
|
||||
|
||||
private:
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
QPointF m_dragBeginPos;
|
||||
void partClickedEvent() override;
|
||||
|
||||
bool m_toggleState = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user