-
Notifications
You must be signed in to change notification settings - Fork 4
Notifications
Notifications are sent by Interactive Elements to registered listeners.
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 an instance of your listener implementation.
auto scrollListener = std::shared_ptr<ScrollListener>(new ScrollListener);
eyegui::registerSensorListener(pLayout, "scroll_up", scrollListener);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 an instance of your listener implementation.
auto modeListener = std::shared_ptr<ModeListener>(new ModeListener);
eyegui::registerButtonListener(pLayout, "mode", modeListener);To create a listener, one has to implement the abstract class given in the interface called KeyboardListener.
class TypingListener : public eyegui::KeyboardListener
{
public:
void virtual keyPressed(eyegui::Layout* pLayout, std::string id, std::u16string value)
{
word += value; // example
}
void virtual keyPressed(eyegui::Layout* pLayout, std::string id, std::string value) {}
};The interface expects a pointer to the layout, the id of the button and a weak pointer to an instance of your listener implementation.
auto typingListener = std::shared_ptr<TypingListener>(new TypingListener);
eyegui::registerKeyboardListener(pLayout, "keyboard", typingListener);