Re: Understanding JsInterop

2018-02-21 Thread Paul Stockley
Try using Js.uncheckedCast from jsinterop-base On Tuesday, February 20, 2018 at 1:59:44 PM UTC-5, Scott Shumway wrote: > > I'm still unable to do this. I want to be able to get a DOMRect from a > com.google.gwt.dom.client.Element with JsInterop. If I cast to this Element > class, or even

Re: Understanding JsInterop

2018-02-20 Thread Scott Shumway
I'm still unable to do this. I want to be able to get a DOMRect from a com.google.gwt.dom.client.Element with JsInterop. If I cast to this Element class, or even ((HasGetBoundingClientRect) (Object) element), I will get a (runtime) java.lang.ClassCastException. The cast to Object works, of

Re: Understanding JsInterop

2018-02-15 Thread Scott Shumway
Thanks! I didn't think of casting to Object first... I'll give it a try. I generally turn on as many compiler warnings as I can stand to get my code to compile through a strict filter, but I was getting outright errors. Also, namespace with "Element", Doh! of course... On Thursday, February

Re: Understanding JsInterop

2018-02-15 Thread Thomas Broyer
On Thursday, February 15, 2018 at 11:01:41 AM UTC+1, Vassilis Virvilis wrote: > > Amazing trick! > > Obvious if you think about it - but very difficult to think it initially > (for us mere mortals). > Well, when you write "element.getBoundingClientRect" in JS (without the parenthesis), this

Re: Understanding JsInterop

2018-02-15 Thread Vassilis Virvilis
Amazing trick! Obvious if you think about it - but very difficult to think it initially (for us mere mortals). Vassilis On Thu, Feb 15, 2018 at 11:53 AM, Thomas Broyer wrote: > > > On Thursday, February 15, 2018 at 10:21:59 AM UTC+1, Scott Shumway wrote: >> >> Greetings

Re: Understanding JsInterop

2018-02-15 Thread Thomas Broyer
On Thursday, February 15, 2018 at 10:21:59 AM UTC+1, Scott Shumway wrote: > > Greetings > > I am trying to get a DOMRect from an Element. I can do this with JSNI, but > have been unable to make a JsInterop version. Here's what I have: > > public final class DOMRect extends JavaScriptObject > {

Understanding JsInterop

2018-02-15 Thread Scott Shumway
Greetings I am trying to get a DOMRect from an Element. I can do this with JSNI, but have been unable to make a JsInterop version. Here's what I have: public final class DOMRect extends JavaScriptObject { // returns DOMRect or null public static native DOMRect getBoundingClientRect(Element

Re: Trouble understanding JsInterop

2017-04-12 Thread Thomas Broyer
On Wednesday, April 12, 2017 at 9:01:37 AM UTC+2, DavidN wrote: > > There is one thing people keep on repeating: > You can only invoke the exported class/method when the gwt app is loaded. > Just like with any asynchronously loading script. For example, the Google Analytics snippet

Re: Trouble understanding JsInterop

2017-04-12 Thread Philipp
The JsInterop part worked now - in the end it was the missing -generateJsInteropExports and my confusion when to use $wnd and when not. On Tuesday, 11 April 2017 17:30:39 UTC+2, Thomas Broyer wrote: > > > > On Tuesday, April 11, 2017 at 4:53:24 PM UTC+2, Philipp Gloor wrote: >> >> Where do I use

Re: Trouble understanding JsInterop

2017-04-12 Thread David
There is one thing people keep on repeating: You can only invoke the exported class/method when the gwt app is loaded. Is there a GWT supported default way that would allow this ? Otherwise I guess you would need to add a callback mechanism in the EntryPoint (Using JsInterop) On Tue, 11 Apr

Re: Trouble understanding JsInterop

2017-04-11 Thread Thomas Broyer
On Tuesday, April 11, 2017 at 4:53:24 PM UTC+2, Philipp Gloor wrote: > > Where do I use $wnd.test.JsOpClass()? It doesn't work within

Re: Trouble understanding JsInterop

2017-04-11 Thread Vassilis Virvilis
It should work but you also have to make sure that GWT code is loaded. So after the crash - hit F12 go to console and try to reference $wnd.test.JsOpClass or put a console print inside onModuleLoad to see when GWT code is loaded: before or after the crash Vassilis On Tue, Apr 11, 2017 at 5:52

Re: Trouble understanding JsInterop

2017-04-11 Thread Philipp Gloor
Where do I use $wnd.test.JsOpClass()? It doesn't work within

Re: Trouble understanding JsInterop

2017-04-11 Thread Vassilis Virvilis
Hi, 1. With jsinterop you won't need any JSNI normally. 2. If you have older JSNI code that calls your new code (can't really happen) you can a) use new $wnd.test.JsOpClass(); with -generateJsInteropExports as Thomas suggested b) use the old syntax found here

Re: Trouble understanding JsInterop

2017-04-11 Thread Philipp Gloor
NB: I changed the namespace from test to pdf -> that's why it is now $wnd.pdf is undefined. On 11 April 2017 at 16:29, Philipp Gloor wrote: > Can I access Classes and Methods decorated with JsType/JsMethod from > anywhere within GWT granted I'm inside a JSNI block? Or

Re: Trouble understanding JsInterop

2017-04-11 Thread Philipp Gloor
Can I access Classes and Methods decorated with JsType/JsMethod from anywhere within GWT granted I'm inside a JSNI block? Or is it restricted to packages? I added the -generateJsInteropExports to the run configuration arguments but when I try to create a new object JsOpClass() it tells me

Re: Trouble understanding JsInterop

2017-04-11 Thread Thomas Broyer
On Tuesday, April 11, 2017 at 10:43:06 AM UTC+2, Philipp wrote: > > If I have a java class and I mark it with @JsType I create a contract > between Java and Javascript that I can use this class with it's given Java > name in Javascript - is this correct? > > package com.test.workertest.shared;

Trouble understanding JsInterop

2017-04-11 Thread Philipp
If I have a java class and I mark it with @JsType I create a contract between Java and Javascript that I can use this class with it's given Java name in Javascript - is this correct? package com.test.workertest.shared; import com.google.gwt.core.shared.GWT; import jsinterop.annotations.*;