problem with the card and the Browser

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ferrandjames
Posts: 20
Joined: Tue Mar 01, 2011 11:23 pm

problem with the card and the Browser

Post by ferrandjames » Wed Mar 02, 2011 9:49 am

Hello, I just put a browser on a Card2 but when I put a button back on a card1, the browser still appears on the card1, how it should not appear on card1?

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: problem with the card and the Browser

Post by Klaus » Wed Mar 02, 2011 1:40 pm

Hi James,

a "browser" object is always an OVERLAY on the screen and not a "real" LiveCode object.
This way this object will always be on the screen, does not care about stacks and cards
and will leave the responsibility to YOU, the developer :D

You will need to hide or close (delete) the browser when switching cards/stacks!

Check menu: Help -> iOS Release Notes
to get more info about "iOS Native Controls"


Best

Klaus

ferrandjames
Posts: 20
Joined: Tue Mar 01, 2011 11:23 pm

Re: problem with the card and the Browser

Post by ferrandjames » Wed Mar 02, 2011 2:16 pm

thank you for your quick answer, but I'm sorry I'm newbie, and how to hide or does your close (delete) the Browser ....

thank you in advance

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: problem with the card and the Browser

Post by Klaus » Wed Mar 02, 2011 2:36 pm

Hi James,

newbie or not, as I wrote in my last mail, you can find the answer in teh LiveCode menus!

Check menu: Help -> iOS Release Notes
to get more info about "iOS Native Controls"

EDIT:
Here some nore hints:
...
## Delete the iOS object:
iphoneControlDelete id
...
## Change its visibility:
iphoneControlSet id, "visible", false
...

Best

Klaus

ferrandjames
Posts: 20
Joined: Tue Mar 01, 2011 11:23 pm

Re: problem with the card and the Browser

Post by ferrandjames » Wed Mar 02, 2011 4:40 pm

I created a button function as return, and I have write code like "iphoneControlDelete isBrowserId" and its not working ... I do not understand ...

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: problem with the card and the Browser

Post by Klaus » Wed Mar 02, 2011 5:33 pm

Hi James,

please post the script(s) that you use to CREATE the browser on iOS!

You may need to declare the object ID as a global variable to be able
to use it with "iPhonedelete ID" or "iphoneControlSet id,..."


Best

Klaus

ferrandjames
Posts: 20
Joined: Tue Mar 01, 2011 11:23 pm

Re: problem with the card and the Browser

Post by ferrandjames » Thu Mar 03, 2011 2:58 pm

the code of the cards of browser :

# declare the local id of the browser we are creating
global sBrowserId

# when the card is opened make sure that default settings are configured
on preOpenCard
# quit if we are not on a mobile device
if the environment is not "mobile" then
exit preOpenCard
end if
# create the browser
iphoneControlCreate "browser"
put the result into sBrowserId
# set up the basic defaults
iphoneControlSet sBrowserId, "rect", the rect of group "Browser"
iphoneControlSet sBrowserId, "visible", "true"
iphoneControlSet sBrowserId, "url", "url-of-google-example"
end preOpenCard

on closeCard
if the environment is not "mobile" then
exit closeCard
end if
# destroy the browser we created
iphoneControlDestroy sBrowserId
iphoneControlDelete sBrowserId
end closeCard

# provide a status message that indicates loading has started
on browserStartedLoading pUrl
put "Started loading:" && pUrl into field "Status"
end browserStartedLoading

# provide a status message that indicates loading has finished
on browserFinishedLoading pUrl
put "Finished loading:" && pUrl into field "Status"
put pUrl into field "Url"
end browserFinishedLoading

# provides a status message that indicates the reason for loading
on browserLoadRequest pUrl
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

# a handler that executes an action invoked by the controls
on doAction pAction
iphoneControlDo sBrowserId, pAction
end doAction
# a handler that loads the URL
on goUrl pUrl
iphoneControlSet sBrowserId, "url", pUrl
end goUrl

and i have a create a button with this code :

on mouseUp
iphoneControlDelete sBrowserId
#iphoneControlSet sBrowserId, "visible", false
end mouseUp


its still not working ...

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: problem with the card and the Browser

Post by Klaus » Thu Mar 03, 2011 3:04 pm

Hi James,

the problem is the ID that you get when you initialize (create new) browser control.
It IS already declared as a global variable, but you need to declare it every time in every
scripts/handlers you use this variable!

Do this:

Code: Select all

on mouseUp
   GLOBAL sBrowserId
   iphoneControlDelete sBrowserId
end mouseUp
That should do the trick!

Please check all these stacks here to get the basics of LiveCode:
http://www.runrev.com/developers/lesson ... nferences/

Best

Klaus

ferrandjames
Posts: 20
Joined: Tue Mar 01, 2011 11:23 pm

Re: problem with the card and the Browser

Post by ferrandjames » Mon Mar 07, 2011 6:37 pm

Thank you a thousand times, Klaus, you helped me, and it works nikel ... Sincerely, James

Post Reply