Skip to content
Raphael Menges edited this page Sep 21, 2015 · 7 revisions

Notifications are sent by interactive elements to registered listeners.

Sensor listener

To create a listener, one has to implement the abstract class given in the interface called SensorListener.

class ScrollListener : public eyegui::SensorListener
{
public:
    void virtual penetrated(eyegui::Layout* pLayout, std::string id, float amount)
    {
      scrolling = amount; // example
    }
};

The interface expects a pointer to the layout, the id of the sensor and a weak pointer to a instance of your listener implementation.

auto scrollListener = std::shared_ptr<ScrollListener>(new ScrollListener);
eyegui::registerSensorListener(pLayout, "scroll_up", scrollListener);

Button listener

To create a listener, one has to implement the abstract class given in the interface called ButtonListener.

class ModeListener : public eyegui::ButtonListener
{
public:
    void virtual hit(eyegui::Layout* pLayout, std::string id)
    {
      toggleMode(); // example
    }
    void virtual down(eyegui::Layout* pLayout, std::string id) {}
    void virtual up(eyegui::Layout* pLayout, std::string id) {}
};

The interface expects a pointer to the layout, the id of the button and a weak pointer to a instance of your listener implementation.

auto modeListener = std::shared_ptr<ModeListener>(new ModeListener);
eyegui::registerButtonListener(pLayout, "mode", modeListener);

Clone this wiki locally