是否可能触发c ++代码,由minko中的html事件引发? [英] is it possible to trigger c++ code, intiated by html events in minko?
问题描述
使用 minko ,html overlay功能,是否可以从html向c ++代码发送事件?
提供的示例清楚地展示了如何从c ++向html发送事件(通过递增计数器并将其反映在html中),可以让通信
是的。
p>HTML DOM事件被封装并作为C ++信号提供。因此,您可以执行以下操作:
dom-> getElementById(my-element-id) - > onclick ) - > connect(
[](dom :: AbstractDOMMouseEvent :: Ptr event)
{
// do something ...
}
);
实际上是在同一个例子中: https://github.com/aerys/minko/blob/master/example/html-overlay/ src / Main.cpp#L110
您也可以使用 AbstractDOM :: sendMessage )
方法在C ++或 Minko.sendMessage()
你可以使用C ++中的 AbstractDOM :: onmessage()
和 Minko.addEventListener(message,yourCallbackFunction)
。
请注意,您也可以在C ++代码中调用 AbstractDOM :: eval()
码。这是我们如何实现大部分的事情。
Using minko, "html overlay" feature, is it possible to send events to c++ code from html?
The example provided, with the framework clearly demonstrate how to send events from c++ towards html (by incrementing a counter and having it reflect in html), is it possible to have the communication the other way around ?
Thanks.
Yes.
HTML DOM events are wrapped and made available as C++ signals. So you can do something like:
dom->getElementById("my-element-id")->onclick()->connect(
[](dom::AbstractDOMMouseEvent::Ptr event)
{
// do something...
}
);
It's actually done in the same example: https://github.com/aerys/minko/blob/master/example/html-overlay/src/Main.cpp#L110
You can also send and receive "messages" both ways using the AbstractDOM::sendMessage()
method in C++ or Minko.sendMessage()
function in JS. You can listen to those messages using AbstractDOM::onmessage()
in C++ and Minko.addEventListener("message", yourCallbackFunction)
.
Note that you can also call AbstractDOM::eval()
in your C++ code to execute JavaScript code. It's how we've implemented most of the things actually.
这篇关于是否可能触发c ++代码,由minko中的html事件引发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!