Added native event payload on the event listener
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "eventsmap.h"
|
||||
|
||||
std::unordered_map<std::string, int> EventsMap::events {
|
||||
std::unordered_map<std::string, int> EventsMap::eventTypes {
|
||||
{ "None", QEvent::None },
|
||||
{ "ActionAdded", QEvent::ActionAdded },
|
||||
{ "ActionChanged", QEvent::ActionChanged },
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "eventwidget.h"
|
||||
#include "deps/spdlog/spdlog.h"
|
||||
#include <napi.h>
|
||||
|
||||
void EventWidget::subscribeToQtEvent(std::string evtString){
|
||||
try {
|
||||
int evtType = EventsMap::events.at(evtString);
|
||||
int evtType = EventsMap::eventTypes.at(evtString);
|
||||
this->subscribedEvents.insert({static_cast<QEvent::Type>(evtType), evtString});
|
||||
spdlog::info("EventWidget: subscribed to {}", evtString.c_str());
|
||||
} catch (...) {
|
||||
spdlog::info("EventWidget: Couldn't subscribe to qt event {}. If this is a signal you can safely ignore this warning", evtString.c_str());
|
||||
}
|
||||
@@ -16,7 +18,8 @@ void EventWidget::event(QEvent* event){
|
||||
QEvent::Type evtType = event->type();
|
||||
std::string eventTypeString = subscribedEvents.at(evtType);
|
||||
this->emitOnNode->call([=](Napi::Env env, std::vector<napi_value>& args) {
|
||||
args = { Napi::String::New(env, eventTypeString) };
|
||||
Napi::Value nativeEvent = Napi::External<QEvent>::New(env, event);
|
||||
args = { Napi::String::New(env, eventTypeString), nativeEvent };
|
||||
});
|
||||
} catch (...) {
|
||||
// Do nothing
|
||||
|
||||
Reference in New Issue
Block a user