Scrolling down vertically in a revBrowser Object

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Scrolling down vertically in a revBrowser Object

Post by montymay » Tue Mar 03, 2015 4:33 am

I am using LC 7.0. I want to open a web page in a revBrowser object and set the vscroll property so that it automatically scrolls down a specified number of pixels. The documents being opened are all online PDFs. The following script has no effect; the web page opens at the top and does not scroll down:

Code: Select all

  revBrowserSet lBrowserID,"rect", the rect of graphic "rectRevBrowser"
  revBrowserSet lBrowserID, "url", "http://www.guamcourts.org/CompilerofLaws/GCA/01gca/1gc001.PDF"
  revBrowserSet lBrowserID, "vscroll", 5000 --or whatever number I need to specify
I have tried both with and without quotation marks around the number, with the same result. Does anyone see my mistake or experience the same results?

Monty

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Scrolling down vertically in a revBrowser Object

Post by MaxV » Tue Mar 03, 2015 4:51 pm

It works, but you have to wait that the page is loaded, for example:
One button code:

Code: Select all

on mouseUp
   put revBrowserOpen(the windowId of this stack, "http://www.livecode.com") into lBrowserId
   set the browid of graphic "rectRevBrowser" to lBrowserId
   revBrowserSet lBrowserID,"rect", the rect of graphic "rectRevBrowser"
end mouseUp
after loading another button code:

Code: Select all

on mouseUp
   put the browid of graphic "rectRevBrowser" into lBrowserId
   revBrowserSet lBrowserID, "vscroll", 5000 
end mouseUp
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Scrolling down vertically in a revBrowser Object

Post by montymay » Mon Mar 09, 2015 3:31 am

Thank you for your reply. I divided my script into two parts. First I load the PDF by clicking on a button. Then I trigger the following script in a different control:

Code: Select all

global gBrowserID  --the browser ID of the loaded browser. I think a global variable is needed in my case because the script is in different controls.

on mouseUp
   revBrowserSet  gBrowserID, "rect", the rect of grc "rectRevBrowser"
   revBrowserSet gBrowserID, "vscroll", 50000
end mouseUp
The code does nothing. The page will not scroll down.

Your code generates a error for me. I do not understand the line "put the browid of graphic "rectRevBrowser" into lBrowserId." Could you explain it?

Thanks again for your reply.

Monty

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Scrolling down vertically in a revBrowser Object

Post by MaxV » Wed Mar 11, 2015 4:27 pm

Variables are not maintained outside a message. You have to put values inside custom properties. A custom property is a new property that you define in order to see the values from any message and/or control.
You need to keep the ID of the browser, so you store the ID value into the custom property browid (I don't have much imagination for names).

Code: Select all

set the browid of graphic "rectRevBrowser" to lBrowserId
Now you can indicate the correct browser to revBrowserSet:

Code: Select all

on mouseUp
   put the browid of graphic "rectRevBrowser" into lBrowserId
   revBrowserSet lBrowserID, "vscroll", 5000
end mouseUp
You could store the value in the current card, in a button, wherever you like:

Code: Select all

set the browid of this card to lBrowserId

Code: Select all

set the browid of this stack to lBrowserId

Code: Select all

set the browid of this button to lBrowserId

Code: Select all

set the browid of me to lBrowserId
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Scrolling down vertically in a revBrowser Object

Post by jacque » Thu Mar 12, 2015 4:43 pm

Script local variables will retain their values between handlers as well, which is handy when you don't want to store a permanent value in the stack. They're ideal for temporary values like native control IDs.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Scrolling down vertically in a revBrowser Object

Post by montymay » Mon Feb 08, 2016 8:29 am

It's been a year since my last post in this string, and I am again interested in using the "vscroll" property of the revBrowser. I want to load local PDF documents into the revBrowser and get the document to scroll down a pre-determined number of pixels when I select a line in a locked, listBehavior field that contains the table of contents for the document. I now understand better custom properties and the discussion above about storing the instanceID in a custom property in an object.

The document fully loads, but when I click the field, nothing happens. Does this feature actually work?

Here the code for opening the PDF:

Code: Select all

on mouseup
   resetcard
   put revBrowserOpenCEF(the WindowID of this stack) into gBrowserID
   set the browserID of grc "rulebrowser" to gBrowserID
  revBrowserSet gBrowserID, "rect", the rect of grc "ruleBrowser"
  revBrowserSet gBrowserID, "url", "file:///cts/courtRules/"&tRules&".pdf"
end mouseup

on resetCard
   repeat for each item gBrowserID in revBrowserInstances()
      revBrowserClose gBrowserID
   end repeat
end resetCard
Here is the code for the field:

Code: Select all

on mouseup
   put the browserID of grc "ruleBrowser" into gBrowserID
   revBrowserSet gBrowserID, "vscroll", "4000"
end mouseup
Thank you for any suggestions.

Monty

Post Reply