0

I am using minko and html-overlay feature. In my overlay onload()->connect() method I have the following statements:

...

gameInterfaceDom = dom;
but1 = gameInterfaceDom->getElementById("id_but1");    //trouble here !
but2 = gameInterfaceDom->getElementById("id_but2");


LOG_INFO("Going to bind onclick events...");
if( but1 != nullptr )
{
    onBut1 = but1->onclick()->connect(
    [](dom::AbstractDOMMouseEvent::Ptr event)
    {
      // do something...
        LOG_INFO("clicked button 1");
    });
}

if( but2 != nullptr )
{
    onBut2 = but2->onclick()->connect(
    [](dom::AbstractDOMMouseEvent::Ptr event)
    {
      // do something...
        LOG_INFO("clicked button 2");
    });
}

...

Compiling and running under linux64 works perfectly even if the loaded html does not contain the but1 and but2 IDs, however, the same code crashes for Android and web / HTML5 (if expected IDs are not found) with the following error :

exception thrown: TypeError: Minko.tmpElement is null

Is there a workaround for such case, or is it mandatory to have the expected IDs in c++ also defined in html ?

Thx.

Jeux
  • 5
  • 5
  • I tried to use try/catch block around getElementById but that didn't work either... – Jeux Mar 16 '15 at 22:04
  • did you properly wait for the `AbstractDOM::onload()` signal before trying to get things from the DOM? – Jean-Marc Le Roux Mar 23 '15 at 07:14
  • Yes, similarly to the html-overlay sample: `onloadSlot = overlay->onload()->connect([=](minko::dom::AbstractDOM::Ptr dom, std::string page) { if (!dom->isMain()) return; //if (dom->fileName() == "interface.html") { //my code here } });` better formatting : [pastebin link](http://pastebin.com/UQG9FgqF) – Jeux Mar 24 '15 at 05:27

0 Answers0