Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
sday
Posts: 11
Registered: ‎02-17-2009
My Device: Not Specified

Browser Field and Key/Track listeners

[ Edited ]

I've searched to no avail. 

 

When embedding a browser in my own app, is there a way to intercept keystrokes and trackwheel messages?  I would like to provide a custom interface for browsing our internal company website that does not rely on javascript.  I'm trying to reduce bandwidth among other things.

 

I've tried attaching keylisteners to the mainscreen, and even theUiApplication.  

 

 

public class RawHTMLBrowserSample extends UiApplication

...

this.addKeyListener(new TestKeyPadListener());

...

private class TestKeyPadListener implements KeyListener
{
public boolean keyChar(char key, int status, int time)
{
Alert.startAudio(TUNE_LOW, 50);

 

Once the embedded browser displays the content, it seems to own the application.  All keystrokes and trackwheel events are captured by the underlying browser which leaves me with no ability to customize my inteface.

 

For instance, I'd like to know when the user clicks on a particular link that may require me to do something additional, or set the scroll speed on certain pages to allow the user to scroll quicker through certain content.  etc.

 

Anyone know of a way to work around this?

 

Thanks

 

Message Edited by sday on 02-17-2009 01:53 PM
Please use plain text.
Developer
Posts: 107
Registered: ‎09-25-2008
My Device: Not Specified

Re: Browser Field and Key/Track listeners

Have you tried subclassing the MainScreen and overriding the keyUp/keyDown/keyChar methods to hijack the input? You should probably ask this question in the Java development forum.
Please use plain text.
New Developer
sday
Posts: 11
Registered: ‎02-17-2009
My Device: Not Specified

Re: Browser Field and Key/Track listeners

Everything traps fine until the browser displays it's content.  The reason I put it in here is because I think the browser might somehow be trapping everything before the app gets it... which I thought was strange, but maybe it has something to do with it being in a thread?  I'm pretty new with bb development so I feel like a blowfish at a porcupine convention. 
Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Browser Field and Key/Track listeners

The browser field itself would get the first access to input.  You could create a custom field that overrides the input methods and cast the Field returned to from the browserContent.getDisplayableContent() call.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
sday
Posts: 11
Registered: ‎02-17-2009
My Device: Not Specified

Re: Browser Field and Key/Track listeners

hmmm.  Thanks for the idea, I'll give that a try and see what I can get out of that.  I guess I could use that same idea to trap the trackwheel click.  Is there a way I can ask the Browserfield what is being clicked on?  They really should include some events like, "before link click", "after link click", etc.. 

 

Thanks for the help

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Browser Field and Key/Track listeners

There is no way to determine what a user clicked on within the browser field.  You can get information on requests the user is making (i.e. when they are loading a new page after clicking a URL) within the eventOccured method of the browser field sample.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
sday
Posts: 11
Registered: ‎02-17-2009
My Device: Not Specified

Re: Browser Field and Key/Track listeners

Thanks for the input.  I've been looking around to see if anyone has create a java class that can render html, but again to no avail.  In order to get the functionality I want it looks like I'll have to use something like the library at http://htmlparser.sourceforge.net/

 

The problem is they implement a few classes that isn't supported on the blackberry in even the smallest footprint lexer.  

 

import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URLConnection;
import java.util.Vector; // I think this is the only class I could find supported by the BB implementation.

 

Thanks again, I'll keep searching for an alternate method outside the BB browser.  If anyone knows of a class, open source or for pay, that give the developer full control, please let me know.

 

-Steve

Please use plain text.