ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
app->resize(w, h);
if (app->mResizeCb)
- app->mResizeCb(app->mResizeData);
+ app->mResizeCb(app->mResizeData, nullptr);
}
static void
{
EvasApp *app = (EvasApp *)ecore_evas_data_get(ee, "app");
if (app->mExitCb)
- app->mExitCb(app->mExitData);
+ app->mExitCb(app->mExitData, nullptr);
ecore_main_loop_quit();
ecore_evas_free(ee);
}
+static Eina_Bool
+on_key_down(void *data, int type, void *event)
+{
+ Ecore_Event_Key *keyData = (Ecore_Event_Key *)event;
+
+ EvasApp *app = (EvasApp *) data;
+ if (app && app->mKeyCb)
+ app->mKeyCb(app->mKeyData, (void *)keyData->key);
+
+ return false;
+}
+
EvasApp::EvasApp(int w, int h)
{
if (!ecore_evas_init())
ecore_evas_data_set(mEcoreEvas, "app", this);
ecore_evas_callback_resize_set(mEcoreEvas, _on_resize);
ecore_evas_callback_delete_request_set(mEcoreEvas, _on_delete);
+ ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, on_key_down, this);
ecore_evas_show(mEcoreEvas);
mEvas = ecore_evas_get(mEcoreEvas);
#include <Evas.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
+#include <Ecore_Input.h>
-typedef void (*appCb)(void *userData);
+typedef void (*appCb)(void *userData, void *extra);
class EvasApp
{
public:
Efl_VG * root() const {return mRoot;}
void addExitCb(appCb exitcb, void *data) {mExitCb = exitcb; mExitData = data;}
void addResizeCb(appCb resizecb, void *data) {mResizeCb = resizecb; mResizeData = data;}
+ void addKeyCb(appCb keycb, void *data) {mKeyCb = keycb; mKeyData = data;}
public:
int mw;
int mh;
void *mResizeData;
appCb mExitCb;
void *mExitData;
+ appCb mKeyCb;
+ void *mKeyData;
};
#endif //EVASAPP_H