OK. I couldn't figure out how to have an overlay popping up over a card, so instead I took the card from the browser stack that came with LC and with minimal alterations, integrated it into my stack on a card called "browser." Then when I have a url that I want the user to be able to open, they click on a button which I will call "URL Button" for now, which has the following script:
on mouseUp
mark this card
go to card "browser"
end mouseUp
On the browser card, I have a button called "DONE" with the following script to bring them back to the card where they left off when they are done looking at the url I have sent them to:
on mouseUp
go to next marked card
end mouseUp
Then I used the script that had come with the example on the card itself and it opens Google fine but I am having trouble figuring out how to have it open the link I want it to open rather than the Google. In the following script, there is a line to "set up a suitable initial url:"
iphoneControlSet sBrowserId, "url", "
http://www.google.com"
Of course I can change the "
http://www.google.com" to whatever I want in the browser card but I would like to be able to change it from the URL Button as there are several different url's in the stack and I only want one browser card. The url would be in the button with the script:
on mouseUp
mark this card
go to card "browser"
open url "
http://www.whatever.com" (or something like that???)
end mouseUp
BUT that doesn't seem to work?
The card script from the browser card:
-- We use this variable to store the id of the UIWebView native
-- control.
local sBrowserId
on preOpenCard
if the environment is not "mobile" then
exit preOpenCard
end if
-- Create our browser control and store the id
iphoneControlCreate "browser"
put the result into sBrowserId
-- Native controls start off invisible
iphoneControlSet sBrowserId, "visible", "true"
-- Set up a suitable initial url
iphoneControlSet sBrowserId, "url", "
http://www.google.com"
-- Make sure everything is the right size
resizeStack
end preOpenCard
on closeCard
if the environment is not "mobile" then
exit closeCard
end if
-- Destroy the control, if we fail to do this native UIViews
-- will just accumulate
iphoneControlDelete sBrowserId
end closeCard
on resizeStack
if the environment is not "mobile" then
exit resizeStack
end if
-- Adjust the size of the URL entry field
set the rect of field "URL" to the left of field "URL", the top of field "URL", the width of this card - 4, the bottom of field "URL"
-- Adjust the size of the browser view
set the rect of group "Browser" to the left of group "Browser", the top of group "Browser", the width of this card - 4, the height of this card - 10
-- Adjust the status field
set the rect of field "Status" to 4, the bottom of group "Browser" + 4, the width of this card - 4, the height of this card - 4
-- Now adjust the control itself
iphoneControlSet sBrowserId, "rect", the rect of group "Browser"
end resizeStack
--------
-- This message is received after a request has been allowed and
-- loading is starting
on browserStartedLoading pUrl
put "Started loading:" && pUrl into field "Status"
end browserStartedLoading
-- This message is received when a page has been completely
-- loaded and is displayed to the user
on browserFinishedLoading pUrl
put "Finished loading:" && pUrl into field "Status"
put pUrl into field "Url"
end browserFinishedLoading
-- This message is received when a new url is requested. Passing it
-- causes the load to go ahead, otherwise it does not.
on browserLoadRequest pUrl, pReason
answer "Do you want to load:" && pUrl with "Yes" and "No"
if it is "Yes" then
pass browserLoadRequest
else
put "Refused:" && pUrl into field "Status"
end if
end browserLoadRequest
--------
-- This handler is invoked by our Back/Forward/Stop/Refresh buttons
-- we just pass the request onto the control.
command doAction pAction
if the environment is not "mobile" then
exit doAction
end if
iphoneControlDo sBrowserId, pAction
end doAction
-- This handler is invoked when the url field is closed after editing.
-- It causes a new url to be requested
command goUrl pUrl
if the environment is not "mobile" then
exit goUrl
end if
iphoneControlSet sBrowserId, "url", pUrl
end goUrl