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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Adobe AIR Development

Reply
New Developer
vvn_murali
Posts: 61
Registered: ‎06-07-2011
My Carrier: Employee

QNXStageWebView findString method scroll problem

Hi every one,

 

I am using QNXStageWebView in my app, I need to search the content in the page so I am using findString method for this, its selecting the searching key word but if the search key word is not in the view port its not auto scrolling to key word position,. I thought we have two methods to do this if we know the key word position in pixels they are scrollBy and scrollPosition, but I don't know how to determine the key word position. Any body having any idea about this, please share with me, I am waiting for your reply. 

 

Thanks in advance.

Please use plain text.
BlackBerry Development Advisor
dmalik
Posts: 339
Registered: ‎02-22-2012
My Carrier: Bell

Re: QNXStageWebView findString method scroll problem

Good question...

 

Just an idea - Reload the page with your search term but with a regular expression create anchors and highlights on the text that matches. That way the user can go from one match to the next.

 

Dustin

Follow me on Twitter: @dustinmalik
-----------------------------------------------------------------------------------------------------
Keep up to date on BlackBerry development: http://devblog.blackberry.com/
Please use plain text.
Developer
HaTaX
Posts: 93
Registered: ‎08-04-2008

Re: QNXStageWebView findString method scroll problem

[ Edited ]

Here's what I've done and it works well.

 

Add two event listeners, one for TextSelectionChangedEvent.TEXT_SELECTION_CHANGED, and one for FindStringEvent.FIND_STRING.  

 

I handle them both in the same listener and scroll to the appropriate area using something like the following:

 

event.target.scrollBy(((event as TextSelectionChangedEvent).startRect.x-(event.target as QNXStageWebView).scrollPosition.y), ((event as TextSelectionChangedEvent).startRect.y-(event.target as QNXStageWebView).scrollPosition.y)-((stage.stageHeight/2)-30));

 

 

For me, that puts the selection roughly in the middle of the screen just above the keyboard, and below the dialog box that I pop up for text to be input into.

 

It's a complicated command to look at, try breaking it out into its parts and it should be pretty obvious what is happening there.

 

The trick is the TextSelectionChangedEvent, it's got the parameters you need for the scrollBy method.  Additionally I remove the text selection listener if the find comes back false, and you won't see it fire in that instance.

 

Hope that helps you out...

 

Please use plain text.