Revbrowser / How to automatically refresh browserwindows to load "modified" Pdf

Klaus Major klaus at major-k.de
Sat Apr 19 06:20:01 EDT 2008


Hi MadHias :-)

> Hi,
>
> i want to create a little stack, which just opens a pdf file from an  
> url and refreshes this window every 30 seconds to keep track of a  
> possible modification of that pdf.

This is quite simply.

> I tried "Browser Sampler.rev" in examples. But that example is over  
> my head at the moment. I do not need any buttons like back, stop,  
> forward and so on, because there is only one pdf file to be displayed.

The buttons are definitvely not compulsory!

> But the most important thing is, how can i refresh the browser  
> windows automatically without pressing a button and without locking  
> the app when using a loop or a wait.

OK, here we go:

1. Create a stack in the desired size for the PDF.
2. Create an empty image object in that stack in the same size.
This can even be invisible since it is only needed as a reference for  
the dimensons of the browser overlay.

3. Put this into the script of your stack:
###############################

local tRefresh_msg
## Will hold the number of the pending message that will refresh your  
browser as described below..

on openstack

   ## Open/create a new browser:
   put revbrowseropen(the windowID of this stack, empty) into tBrowserID
   set the cBrowserID of this stack to tBrowserID
   ## Could also be a global variable, but I prefer custom props.

   ## Set the dimensions of the newly created browser
   revbrowserset the cBrowserID of this stack, "rect", the rect of img  
"your empty image here, see Nr. 2 above..."

   ## Now load and display your PDF file:
    revbrowserset the cBrowserID of this stack, "url", "http://path to  
your PDF..."
    ## Could also be a local file then use: "file:///path to your  
PDF..."

    send "refresh_display" to this stack in 30 secs
    put the result into tRefresh_msg
    ...
end openstack

## Custom handler to refresh the display of the PDF file (reload)
command refresh_display
    revbrowserrefresh the cBrowserID of this stack
    send "refresh_display" to this stack in 30 secs

   ## Store the number of the pending message, so we can cancel it on  
"closestack"!
    put the result into tRefresh_msg
end refresh_display

on closestack
   ## Cancel the pending message
   cancel tRefresh_msg
end closestack

## You could also add a "resizestack" handler, if needed,
## then you should just set the rect of that "browser" image to the  
rect of cd 1

###############################

That's it :-)

Hope that helps.

> Regards,
>
> Matthias

Best from germanski

Klaus Major
klaus at major-k.de
http://www.major-k.de





More information about the use-livecode mailing list