screen zoom

151 views
Skip to first unread message

ricardo...@gmail.com

unread,
Dec 19, 2012, 12:56:30 PM12/19/12
to codenameone...@googlegroups.com
HI, I am facing the next problem:

I am using a web browser component, but I can't zoom the screen (I am testing my aplication in IOS, multitouch is not working), Any ideas?? 

Thanks  

Steve Hannah

unread,
Dec 19, 2012, 1:25:38 PM12/19/12
to codenameone...@googlegroups.com
I confirm the same behaviour on my apps. I suspect it is related to this:
http://stackoverflow.com/questions/2219685/how-can-i-enable-zoom-in-on-uiwebview-which-inside-the-uiscrollview

"You MUST set scalesPageToFit=YES for any pinching and zooming to work
on a UIWebView"

I suspect that either this setting will need to be exposed in the
CodenameOne API or it will have to be intelligently set based on other
environment settings.

As a workaround, you could create a NativeInterface to which you pass
the WebBrowser's peer component, and set this property yourself.

-Steve
> --
> --
> You received this message because you are subscribed to the Google
> Groups "CodenameOne Discussions" group.
>
> For more information about Codename One please visit
> http://www.codenameone.com/
>
> To post to this group, send email to
> codenameone...@googlegroups.com
> To unsubscribe from this group, send email to
> codenameone-discu...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/codenameone-discussions?hl=en?hl=en
>
>
>



--
Steve Hannah
Web Lite Solutions Corp.

Shai Almog

unread,
Dec 19, 2012, 2:34:03 PM12/19/12
to codenameone...@googlegroups.com
This should be pretty easy to fix. Please file an RFE on this I will add a method to the browser component that will allow enabling zoom. I think the default of leaving it off makes sense for many applications so I won't touch that.

msalc...@gmail.com

unread,
Apr 28, 2013, 5:02:37 PM4/28/13
to codenameone...@googlegroups.com, ricardo...@gmail.com
I saw that this issue now been resolved in the link below. However, I'm having trouble finding the right checkbox to enable the pinch to zoom feature for my web component in the GUI Builder. How can I enable this feature? Thanks.

https://code.google.com/p/codenameone/issues/detail?id=443&can=1&q=zoom

Shai Almog

unread,
Apr 29, 2013, 3:41:32 AM4/29/13
to codenameone...@googlegroups.com, ricardo...@gmail.com, msalc...@gmail.com
Its not exposed in the UI builder currently since this is a niche feature that would just confuse some developers (especially with its weak cross device support).
In the code you need:
WebBroweser wb = ...;
if(wb.getInternal() instanceof BrowserComponent) {
   
((BrowserComponent)wb.getInternal()).setPinchToZoomEnabled(true);
}


msalc...@gmail.com

unread,
Apr 29, 2013, 1:59:31 PM4/29/13
to codenameone...@googlegroups.com, ricardo...@gmail.com, msalc...@gmail.com
Thanks for the response. I'm new to codenameone and would like to know where I need to place the code you gave me? This is a UI builder project and I was under the impression that if you chose to use the UI builder when you created the project in NetBeans, you could not arrange components via hand code. 

msalc...@gmail.com

unread,
Apr 29, 2013, 4:03:05 PM4/29/13
to codenameone...@googlegroups.com, ricardo...@gmail.com, msalc...@gmail.com
Hey so I tried implementing your suggested code in StateMachine.java (not sure if this is where I need to past your code, let me know if it isnt) and for whatever reason I'm getting a "cannot find symbol" error for the WebBrowser class in NetBeans ("WebBrowser" is underlined in red in the code below and won't compile). How can I fix this? Thanks. 

For clarification, "Browserpage" is the form that contains my WebBrowser component.

@Override
   
protected void onCreateBrowserpage() {
       
WebBrowser wb = new WebBrowser();
       
if(wb.getInternal() instanceof BrowserComponent) {
           
((BrowserComponent)wb.getInternal()).setPinchToZoomEnabled(true);
       
}


On Monday, April 29, 2013 3:41:32 AM UTC-4, Shai Almog wrote:

Shai Almog

unread,
Apr 30, 2013, 12:54:35 AM4/30/13
to codenameone...@googlegroups.com, ricardo...@gmail.com, msalc...@gmail.com
You need to select the form containing the web browser component and select the "Events" tab in the GUI builder, then save and click the Before Show event callback.
In NetBeans you will get a method similar to: beforeMyForm(Form f)

Now to get the reference to your WebBrowser just invoke: findMyWebBrowser(f)
which will return a reference to your web browser component.

msalc...@gmail.com

unread,
Apr 30, 2013, 1:08:21 PM4/30/13
to codenameone...@googlegroups.com, ricardo...@gmail.com, msalc...@gmail.com
Thanks works perfect! For anyone else trying to use this feature, make sure you import "com.codename1.components.WebBrowser" into your StateMachine.java file since it is not included by default.
Reply all
Reply to author
Forward
0 new messages