Creating a revBrowser in a separate stack
Posted: Fri Jul 18, 2014 6:55 am
The LiveCode tutorial shows how to open a PDF in the LC browser by using a button and selecting a PDF file in the OS directory, but I want the a PDF file to open automatically in an LC browser when the user clicks on a control. I am trying to use a revBrowser in its own stack.
Here is the script of the initiating button:
Here is the cd script of the browser:
But the file will not display in the browser. The global variable tFile reads, e.g., file:://01-0101%20Title.pdf. Can't find any discussion on this forum. I'm hoping my error is simple and easy to see. Thank you for your help.
Monty May
Here is the script of the initiating button:
Code: Select all
global tFile, sBrowserID
on mouseUp
put the short name of this cd into tFile
replace space with "%20" in tFile -- I read you have to do this when the name has space. True?
put "file://"&tFile&".pdf" into tFile -- I read somewhere that "file://" must be prepended to the filename
go stack "pdf viewer" -- would it be simple to put the browser on a separate cd of the same stack?
end mouseup
Code: Select all
global sBrowserID, tFile
on openCard
browserOpen
end openCard
on browserOpen
put the windowID of this stack into tWinID
put revBrowserOpen(tWinID,"") into sBrowserID
revBrowserSet sBrowserID, "showborder","true"
revBrowserSet sBrowserID, "rect", rect of image "browser image"
end browserOpen
--- the browser does open
BrowserSetURL tFile
on BrowserSetURL
revBrowserSt sBrowserID, "url", tFile
end BrowserSetURL
on mouseup
global tFile
revBrowserClose sBrowserID
delete global tFile
close this stack
end mouseup
Monty May