I've some problem in sending a simple message in overlay-example of Minko library.
I tried use the c++ code of this example without modifying it, while I add a Minko.addListener
in my javascript.
The code of the js is here:
<html>
<head>
</head>
<body>
<script>
Minko.addEventListener("hello", function() {
/* simply replace ":" with <-----> */
document.getElementById("gameTimeLeftSeparator").textContent = "<------>"
});
</script>
<body>
<div id="content">
<div id="scoreBanner">
<div id="scoreBannerBackground"></div>
<div class="teamScore" id="teamScoreRed">0</div>
<div class="teamScore" id="teamScoreBlue">0</div>
<div class="gameTimeLeft" id="gameTimeLeftMn">0</div>
<div class="gameTimeLeft" id="gameTimeLeftSeparator">:</div>
<div class="gameTimeLeft" id="gameTimeLeftSec">0</div>
</div>
</div>
<body >
</body>
</html>
I really don't understand where is the problem. I add the listener, and my very simple function (tested with a classical addListener("click", ... )
is working.
Here I use Minko.addListener("hello", ... )
that is sent by c++ (line 113 of the main.cpp of that example).
What you're doing in your app is a very bad example of C++/JS messaging since you can implement the exact same behavior simply using the C++ DOM API like this:
overlay->mainDOM()->getElementById("gameTimeLeftSeparator")->textContent("<----->");
If what you're trying to do is simply to update a DOM element (content), then the code above (or similar C++ DOM API methods) is the way to go.
If your actual use case cannot be implemented using the C++ DOM API, please update your original question/example accordingly.
Anyway, this:
Minko.addEventListener("hello", ...
should be this of course:
Minko.addEventListener("message", ...
cf this answer