I have a base class and classes that derive from it. The base class Controllableacts as an interface for the input loop, and other classes are extracted from it to get a spot in this loop to receive events such as if a key were pressed.
class Controllable{
public:
virtual void setActive(bool state) { m_active = state; }
virtual void input(Event & e) =0;
private:
bool m_active;
};
class Button : public Controllable{
public:
void setActive(bool state){ m_active = state; }
void input(Event & e) override;
};
Since the class Buttondeals with events from the event queue, setting it to inactive (which removes it from the input loop) can lead to the omission of important events, such as a keystroke, so this requires additional code to put it in a friendly inactive state if it will become active again later.
, , setActive m_active , , ?