mobileControlSet mobileControlDo and bundled html

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

mobileControlSet mobileControlDo and bundled html

Post by dave_probertGA6e24 » Wed May 09, 2012 7:48 am

Hi,

I'm trying to get my head around the mobileControl*** stuff for a "browser" (under IOS - but same for Android eventually!) and I can create the native "browser" object nicely (in the Simulator - haven't tried actual iPad yet), but I cannot persuade it to load a bundled html file I have added to the app.

Stages and testing done so far...:

Code: Select all

mobileControlCreate "browser"
mobileControlSet "rect","10,10,600,600"
mobileControlSet "visible","true"
mobileControlSet "backgroundcolor","white"
all working perfectly so far!

I tested it with a simple mobileControl command to issue an Alert - works perfectly with that. I send a url for an http:///www.runrev.com - and that displays too.

Now I try to access a very simple html (contains a body with "Hello Dave" in it!!) called "test.html" which I have added to the app bundle via the add files part of the standalone creation stuff.
I can see the file exists (in the Simulator) via setting the defaultFolder to the special folder "engine" and sending "the files" into a display field - the html file shows in there fine.

But, when I do a mobileControlSet "url", "test.html" I get nothing.

I have also tried mobileControlDo "load","test.html","" and various variants of that! (with which I can see the 3rd field appearing as text in the browser - which is not actually loading the file)

I've tried all the various special folders, setting the defaultfolder each time and even trying different filename structures - eg. "./test.html", etc.

I cannot seem to simply display the local hml file in the browser object. I must be missing something or just not understanding the Docs or something, 'cos this seems to be such a simple concept for a browser to load a local file.

Please can someone help here?

Please... :)

Cheers,
Dave

PS, if there is some info on how one should setup a local file structure (within the app) containing images, js, css, etc for local display, then I would be really grateful. I don't mean how to write html, etc, (I do that all day long!!) but more what works in terms of html access for images via the local browser - eg paths, etc. And I do understand that this is not a server situation - only 'file' access level (not local 'http')- like a local copy of an html doc.
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: mobileControlSet mobileControlDo and bundled html

Post by Dixie » Wed May 09, 2012 8:41 am

hi...

This works for me... loading the .html file through the 'copy files' pane in the standalone application settings. Then move the file from the 'engine' to the 'documents' folder...'

Code: Select all

local browserID, theURL

on preOpenCard
   if the environment is not "mobile" then exit preOpenCard
   
   put specialFolderPath("documents") & "/dvnav.html" into documentFilePath
   if there is not a file documentFilePath then
      put URL("file:" & specialFolderPath("engine") & "/dvnav.html") into URL("file:" & specialFolderPath("documents") & "/dvnav.html")
   end if
   
   if browserID is empty then
      put "file://" & specialFolderPath("documents") & "/dvnav.html" into theURL
      replace space with "%20" in theURL
      
      iphoneControlCreate "browser"
      put the result into browserID
      iphoneControlSet browserID, "url", theURL
      iphoneControlSet browserID, "visible", "false"
   end if
   
   resizeStack
end preOpenCard
The browser is not visible at this point, I wait until it has finished loading before setting its vis to true using the 'browserFinishedLoading' message..

be well,

Dixie

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: mobileControlSet mobileControlDo and bundled html

Post by dave_probertGA6e24 » Wed May 09, 2012 2:31 pm

Thanks Dixie,

Sometimes I think I'm losing my marbles.

It turned out to be either (or both) of two things. One of which is lack of knowledge of how Livecode works and the other is Forgetfulness!

I didn't realise that the html files had to be in the documents folder ;)

And I had forgotten to add the "file://" at the start of the url!!

Now I can start the experiments and write the App that will find my missing marbles.. I know I left them somewhere ;)

Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: mobileControlSet mobileControlDo and bundled html

Post by FireWorx » Fri May 11, 2012 8:16 pm

I don't think the HTML files have to be in the documents directory for IOS viewing however Dixie I and others like to edit the HTML via live code (for instance inserting GPS coordinated into the HTML of a google map) and then display the HTML in a IOS browser. Making changes to files in the engine folder is not allowed hence the move to the documents folder allows for editing the file. Correct me ifI am wrong Dixie but I think this is the case.
Dave

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

Re: mobileControlSet mobileControlDo and bundled html

Post by Klaus » Sat May 12, 2012 11:51 am

Hi Dave and Dave :D
FireWorx wrote:Making changes to files in the engine folder is not allowed hence the move to the documents folder allows for editing the file.
EX-ACTLY!

Best

Klaus

Post Reply