Page 1 of 1
about closeCard handler
Posted: Sun Nov 23, 2014 11:28 am
by francof
Hi all,
this from the Dictionary:
Sent to the current card when the user goes to another card.
if I've well understood, this handler is runs automatically when, I say, into the mouseUp of a button of current card:
Code: Select all
on mouseUp
go to card "card2"
end mouseUp
it's so?
and this:
Code: Select all
on closeCard
answer "current card closed"
end closeCard
kind regards
franco
Re: about closeCard handler
Posted: Sun Nov 23, 2014 12:19 pm
by Klaus
Yes, that's the way it works!
Or is this a trick question?

Re: about closeCard handler
Posted: Sun Nov 23, 2014 2:20 pm
by francof
Hi Klaus, nice to hear you.
no, no, no trick question, it's only one of my doubts.
I'm trying to use the code of this lesson
http://lessons.runrev.com/m/4069/l/2283 ... er-control but I've some troubles.
I don't now why, the code, adapted to my app, works only the firt time. after that don't
http://forums.livecode.com/viewtopic.php?f=7&t=22115.
I,m doing some tests, and may be I've found something wrong. I've modified the code of the button "X" of the code of the lesson, adding into the mouseUp handler:
Code: Select all
-- Destroy the control, if we fail to do this native UIViews
-- will just accumulate
mobileControlDelete sBrowserId
to exit
I'm still trying
ciao
franco
Re: about closeCard handler
Posted: Sun Nov 23, 2014 2:26 pm
by Klaus
Hi Franco,
"mobileControlDelete sBrowserId" is correct syntax and shold work, of ocurse!
Sorry, no idea what goes wrong in your stack. Can you post more scripts?
Best
Klaus
Re: about closeCard handler
Posted: Sun Nov 23, 2014 6:13 pm
by francof
Hi Klaus,
yes, I haven't posted many data.
well, into a card I've a button who open the card, named cdWeb, where the code of the browser is:
Code: Select all
on mouseUp
answer "Permettere all'applicazione di connettersi ad internet? " with "No" or "Si"
if it is "No" then
exit to top
end if
go to card "cdWeb"
end mouseUp
below the whole script of the card cdWeb. is a bit long but, anyway:
Code: Select all
-- 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
mobileControlCreate "browser"
put the result into sBrowserId
-- Native controls start off invisible
mobileControlSet sBrowserId, "visible", "true"
-- Set up a suitable initial url
--mobileControlSet sBrowserId, "url", "http://www.kickstarter.com/projects/1755283828/open-source-edition-of-livecode"
mobileControlSet sBrowserId, "url", "https://www.google.it/search?q=ricette+pizza"
--mobileControlSet sBrowserId, "url", "https://www.google.it"
-- 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
mobileControlDelete 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 - 40
-- 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
mobileControlSet 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
mobileControlDo 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
mobileControlSet sBrowserId, "url", pUrl
end goUrl
I haven't change it, except for the script of the button Stop (in the lesson code the little "X" button on the top) adding a go to the previous card:
Code: Select all
on mouseUp
doAction "stop"
go to card "crdAbbinamenti"
end mouseUp
ciao
franco
Re: about closeCard handler
Posted: Mon Nov 24, 2014 1:16 pm
by Klaus
Hi franco,
everything looks OK, waht problems do you have?
Best
Klaus
Re: about closeCard handler
Posted: Mon Nov 24, 2014 6:33 pm
by francof
ciao Klaus,
Klaus wrote:Hi franco,
everything looks OK, waht problems do you have?
Best
Klaus
I've a lot of problems

but, about LC apps, at the time is this:
for test the code of my true app. I've created a simply stack, 2 cards. card1 go to the card with the browser code. sometimes it's works, other don't displaying a not avaiable web page message, this below
here the code
best
franco
Re: about closeCard handler
Posted: Mon Nov 24, 2014 11:05 pm
by Klaus
Sometimes it works, sometimes it doesn't?
Are you sure this isn't a simulator issue?
Did you test in on a real device?
Re: about closeCard handler
Posted: Tue Nov 25, 2014 11:34 am
by francof
I tried the zip example above on a true device wi-fi connected to the network.
the browser correctly show me a first page containing the search results, but if I select one of those founded pages, return me, into the url field (if I am correct):
"about blank" ....I haven't internet connection issue.
I will try my true app on emulator and real.
franco