#ifndef _DISPATCH_EVENT_SUPPORT_CPP_
#define _DISPATCH_EVENT_SUPPORT_CPP_
-#include <string>
-#include <JavaScriptCore/JavaScript.h>
-#include <dpl/log/log.h>
-
#include "dispatch_event_support.h"
namespace DispatchEventSupport {
}
}
+void dispatchHwKeyEvent(Evas_Object* ewkView, const std::string key)
+{
+ LogDebug("dispatchHwKeyEvent(" << ewkView << ", " << key << ")");
+
+ if (ewkView != NULL && !key.empty())
+ {
+ std::stringstream script;
+
+ script << "var __event = document.createEvent(\"CustomEvent\");\n"
+ << "__event.initCustomEvent(\"tizenhwkey\", true, true);\n"
+ << "__event.keyName = \"" << key << "\";\n"
+ << "document.dispatchEvent(__event);\n"
+ << "\n"
+ << "for (var i=0; i < window.frames.length; i++)\n"
+ << "{ window.frames[i].document.dispatchEvent(__event); }";
+
+ // just for debugging
+ // LogDebug("script :\n" << script.str());
+
+ ewk_view_script_execute(ewkView, script.str().c_str(), NULL, NULL);
+ }
+}
+
}
#endif //_DISPATCH_EVENT_SUPPORT_CPP_