Hi Peter,
Thanks for the reply. I am unfortunately having some difficulty
getting the above JSNI code to work. With a simplified version of the
code:
public native void setHandler()
/*-{
var callback = function(){
$wnd.alert("test");
};
$wnd.addEventListener("onorientationchange", callback, false);
}-*/;
It generates an exception:
"com.google.gwt.core.client.JavaScriptException: (TypeError): Object
doesn't support this property or method" in the hosted browser.
Creating a separate Safari deferred binding so that the above code
would only be used on my iPhone allows it to compile but still no luck
listening for the "onorientationchange" event. The "test" alert is not
displayed when I change orientation on the iPhone.
Any suggestions on getting the above code to work? I'm not very
experienced to JSNI so this is still a bit new to me.
Thanks,
Jeff J.
On Jun 3, 3:27 pm, Peter Blazejewicz <
peter.blazejew...@gmail.com>
wrote:
> hi Jeff,
>
> in theory it should be sufficient to call some JSNI at some point in
> your code that way (written without IDE):
>
> native void addListener(Handler handler)
> /*-{
> var callback = function(){
> handl...@com.myproject.client.Handler::orientationChanged()();
> };
> $wnd.addEventListener("orientationchange", callback, false);
>
> }-*/;
>
> where handler is trivial:
>
> interface Handler{
> abstract void orientationChanged();}
>
> java class,
>
> (of course that JSNI code could be hidden under java "implementation"
> files to look like native java code without javascript touched),
>
> that was theory, in practise you should also use onload/onunload
> events on Window object to nicely manage different state of browser
> view in mobile safari, e.g. if your page is redirected into different
> page, user pick other page (there could be 8 active pages in iPhone/
> iTouch) and rotate device and then go back to your page,
> see that thread on iphone webdev where that issue was discussed and
> solved (using current version of iPHone/iTouch sdk, not sdk 2.0):
http://groups.google.com/group/iphonewebdev/browse_thread/thread/66fb...