Page 1 of 1

Scrolling down vertically in a revBrowser Object

Posted: Tue Mar 03, 2015 4:33 am
by montymay
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

Re: Scrolling down vertically in a revBrowser Object

Posted: Tue Mar 03, 2015 4:51 pm
by MaxV
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

Re: Scrolling down vertically in a revBrowser Object

Posted: Mon Mar 09, 2015 3:31 am
by montymay
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

Re: Scrolling down vertically in a revBrowser Object

Posted: Wed Mar 11, 2015 4:27 pm
by MaxV
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

Re: Scrolling down vertically in a revBrowser Object

Posted: Thu Mar 12, 2015 4:43 pm
by jacque
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.

Re: Scrolling down vertically in a revBrowser Object

Posted: Mon Feb 08, 2016 8:29 am
by montymay
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