Hi,

I modified the injection code like this:

class MyGraphics
{
 ...

public static void injectSnap ()

{

  LibraryBundle b = GWT.create (LibraryBundle.class);

  FromString f = ScriptInjector.fromString (b.srcSnap().getText());

  f.setWindow (ScriptInjector.TOP_WINDOW);

  f.inject();

}

} 



Then, within my DialogBox I create a GraphicsWidget:

public class GraphicsWidget extends Widget
{
 private static boolean injected = false;
 
 public GraphicsWidget()
 {
  if (!injected)
  {
   MyGraphics.injectSnap ();
   injected = true;
  }

  // set empty div as widget element:  
  Element  e = Document.get().createDivElement();
  setElement(e);
 }

 public void test () // called from Dialog Box
 {
  Element e = getElement();
  testLib(e);
 }

 private native void testLib (Element container)
 /*-{
  //var s = $wnd.Snap (container); // does not work!

  var s = $wnd.Snap (400,400);
  var c = s.circle (150,150,100);  
  
  //container.appendChild (s); // does not work!
 }-*/;
}



WhenI run this, I can see within chrome's inspector that a SVG tag is 
created outside of the scope of the DialogBox/Widget:

<https://lh3.googleusercontent.com/-1-nr1Dkb1MA/UxajnIc4w1I/AAAAAAAAAFs/N1-9ZGzZkdw/s1600/svg.png>

I am still missing some code that "connects" the newly created svg element 
to my widget.
The working code for the SVGJS library contains such a connection:

 private native void testLib(Element container)
 /*-{
  var draw = SVG(container) // here we connect the SVG element to the 
container element
  var text = draw.text('SVG.JS').move(300, 0)
 }-*/;


I am missing such a connection in the current example. It's because there 
seems to be no matching constructor Snap(container). But I also cannot see 
any equivalent statement.

Magnus

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to