Displaying HTML

Monkey Targets Forums/iOS/Displaying HTML

Chroma(Posted 2013) [#1]
Is there a native way in Monkey, particularly iOS, to display HTML ie. a built-in web browser like with BMax?


frank(Posted 2013) [#2]
I would say (haven't tried) that iMonk should do it http://monkeycoder.co.nz/Community/posts.php?topic=954

WebView is supported.


rIKmAN(Posted 2013) [#3]
frank, I guess you didn't read the iMonk thread - it's dead, I spent a week hoping to get hold of it but no luck.


frank(Posted 2013) [#4]
Ah I didn't. Fortunately I need this as well, so i'll get it working. What exactly do you need? I'm going to continue this which I made https://github.com/tluyben/Monkey-WebView by adding iOS / Android to it. I'll try to do that today.


frank(Posted 2013) [#5]
It works https://github.com/tluyben/Monkey-WebView . test.monkey shows how to use it.


rIKmAN(Posted 2013) [#6]
Sounds awesome, will try later when I get home.

Thanks for sharing frank.

EDIT: Works great, tested html5 and iOS :)


frank(Posted 2013) [#7]
You are very welcome. Android is almost done.

Edit: if you can think of improvements / bugs, just post them in Issues in Github; i'll fix them or not :) But if not, I'll tell you why ;)


Difference(Posted 2013) [#8]
This looks great.

Is it possible to use it for local files / strings in code?

That would be great for documentation/help etc.


AdamRedwoods(Posted 2013) [#9]
Is it possible to use it for local files / strings in code?

+1.
Using HTML WebView in monkey would be a great way to make cross-platform UI. .. but you would also need to return events, and that would start to get messy with cross-platform.

Worth a try though.


Beaker(Posted 2013) [#10]
Very handy.


frank(Posted 2013) [#11]
@Difference: sure I can add that, will try this weekend.

@AdamRedwoords: well I solved that here by setting variables which is actually not too bad; you are running Update() anyway which does the same things so you can wrap these variables in Monkey callback which would behave the same way for all intends and purposes.

So;

Update()
gui->Update();
End

And gui->Update() for this control would contain something like;

OnClick()

if noClickCallbackYet And varClicked
noClickCallBackYet = False
doCallback(someMethod, SomeArgs);
End
End

What would be the downside of this? You can hide all cross-platform stuff easily wrapping it in this; it would actually be the same wrapper for most controls anyway.

And if you are thinking of making the UI IN HTML within the webview, then it's also not very hard; you would need to make it Javascript controlled anyway, so you would make JS which is in the webview with the HTML which would pass some basic (not more than that because the rest you actually do in the webview window) stuff, so for instance a 'dosomething' event which will pass JS generates JSON structure to the external interface (this is easy in all webview like controls across all platforms). And Monkey would check for that JSON structure; from that JSON structure you can actually fake any event or whatever within Monkey without having to touch the native part (ever).


Difference(Posted 2013) [#12]
Sounds great!

I have another, slightly convoluted idea: :-)

Would it be possible to have an offscreen WebView, where we could load/render SVG files to a HTML canvas, then get the pixels and copy to a Monkey Image ?


frank(Posted 2013) [#13]
With JS passing it's JSON content (which can include pixels) that should be no problem. I'll try to see if I can make a small demo of the above.


Difference(Posted 2013) [#14]
Very cool. I'm looking forward to testing it.


apinaohjelmoija(Posted 2013) [#15]
This is great!

How about adding support for Windows / Mac / Linux targets (preferrably with Webkit)? :D


AdamRedwoods(Posted 2013) [#16]
How about adding support for Windows / Mac / Linux targets (preferrably with Webkit)? :D

or perhaps...
http://berkelium.org/


frank(Posted 2013) [#17]
Yes, it appears Chromium is very possible; the normal webkit is not as it seems to have a lot of OS specifics and is hard to integrate (for a weekend project; anything is possible ofcourse :). I'll check that later; i'm now setting up communication to/from the webview and testing what would be a good way to manage this.


Skn3(Posted 2013) [#18]
Hey I missed this! Very handy!


CopperCircle(Posted 2013) [#19]
Hows the Android progress?


frank(Posted 2013) [#20]
I am working on 2 games for a client :) So got some delay there; the basics work but it crashes. I'll try to wrap it up today!

Also related: http://www.steamclock.com/blog/2013/05/apple-objective-c-javascript-bridge/
(for people who want to do some background JS processing)
(on all platforms I consider worthwhile it should be capable of using Javascript as a scripting language for Monkey now; I rather would have Lua, especially now that there is Terra, but that seems quite hard because it's not 'everywhere' while JS is)


Lugato(Posted 2013) [#21]
Very Nice!!!! Frank ...

Any news about android version ?


frank(Posted 2013) [#22]
Still didn't have time :( I have been messing around with Admob (on iOS) and in-app billing (for android, ios works fine); I cannot get either to work properly so I wasted a lot of time debugging and asking for help (which no-one is providing unfortunately). When in-app billing is working, i'm going to finish the HTML stuff.


Beaker(Posted 2013) [#23]
I've made a start at adding OpenLayers for google maps, openstreetmaps etc to the Monkey HTML5 target (not in the canvas). It works quite well, and I don't see any reason why you couldn't embed the maps using franks webview into other targets. I'll try and give it a test at some point. Bridging would be very useful here as well.