Hey guys,
i need to use the html5 canvas tag in order to build a small scenegraph library on top of Smart GWT. I didn’t found any “HTML5Canvas” Widget so far and it seems direct manipulation of DOM is some sort of a “bad idea” for handling smart gwt widgets right.
I am using GWT 2.3 and SmartGWT 2.4. I am trying to embed a <canvas> HTML5 element in my SmartGWT app. I tried doing it like it was suggested in the post above:
final HTMLPane pane = new HTMLPane();
pane.setWidth100();
pane.setHeight( 200 );
pane.setContents( "<canvas id='testcanvas'></canvas>" );
The canvas gets embedded properly, but I don’t know where / how to initialize it. To do it I need to call a Javascript function (‘native’) that calls document.getElementById(“testcanvas”). I tried inserting appropriate code in addDrawHandler(…) and in Scheduler.get().scheduleDeferred(…), but getElementById() always returns null. I also tried using addContentLoadedHandler() but the handler never get called. And I tried embedding a <script> tag right after <canvas> inside setContents(), but it doesn’t work either.
Where should I call the initialization Javascript function from?