Jump to content


Photo

Extension: Gmh 1.2.5 (Html Extension)


  • Please log in to reply
43 replies to this topic

#1 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 13 April 2014 - 06:33 AM


4eZYXpO.png
GameMaker: Studio - HTML Extension


Originally created by Schalk updated by Derme


Now Schalk made this awesome extension for GameMaker: HTML5 awhile ago, but unfortunately changes to the GameMaker runner broke it, after some effort I've de-minified and patched the extension. As Schalk hasn't logged in for over a year, I thought I'd go ahead and upload the updated version.
 
I haven't had a chance to test everything so let me know if there are any issues, but I've managed to get a YouTube video working (Link below) so hopefully it'll work as intended.


Description (From original topic)
This extension package provides HTML functionality for Game Maker HTML5 games. That means you can add snippets of HTML code where you want it. The extension also provides functionality to connect the HTML elements to your code, for example when you press a button made in HTML it can make your character jump.
 
Functions (v1.0)
  • gmh_initiate - Activates the extension
  • gmh_canvas_html_add(x,y,html) - Creates a new html element and positions it accordingly. The function returns an integer as an id that must be used in all other functions to access the particular html element.
  • gmh_canvas_html_remove(id) - Destroys the html element, do this when you are done using the element.
  • gmh_canvas_html_hide(id) - Makes the html element invisible.
  • gmh_canvas_html_show(id) - Makes the html element visible.
  • gmh_canvas_html_get_html(id) - Returns the html for the html element.
  • gmh_canvas_html_set_html(id,html) - Sets the html for the html element.
  • gmh_canvas_html_get_x(id) - Returns the x-coordinate for the html element.
  • gmh_canvas_html_get_y(id) - Returns the y-coordinate for the html element.
  • gmh_canvas_html_set_x(id,x) - Sets the x-coordinate for the html element.
  • gmh_canvas_html_set_y(id,y) - Sets the y-coordinate for the html element.
  • gmh_canvas_html_add_event() - Returns the id of the event to be used for other functions. This function must be called first before being able to use events.
  • gmh_canvas_html_callback(id) - This function will return true if the event with the given id has been triggered. If it hasn't been trigger it will return false. This will usually go in the step event of an object.
  • gmh_canvas_html_fire_event(id) - This function is a bit tricky. This "fires" an event with the given id. You would expect this to be in your html code, however can also be used in your game maker project.
Functions (v1.2)
  • gmh_canvas_html_get_value(id); - Gets the value from a HTML object like a textbox, be careful to use this function only with objects that have values
  • gmh_canvas_html_set_value(id, value); - Sets the value from a HTML object like a textbox, be careful to use this function only with objects that have values
Functions (v1.2.5)
  • gmh_canvas_html_active_element() - This returns the type of HTML element that is currently active allowing you to dynamically toggle browser_input_capture(true); (Thanks mudora23)
  • gmh_canvas_html_set_checked(id, value) - This sets the value of a checkbox; (Thanks Trekkie)
  • gmh_canvas_html_get_checked(id) - This gets the value of a checkbox
Links
Live Example (Should work)
Wiki
GameMaker Marketplace
 
Version 1.0 Source Code (via GitHub)
Version 1.2 Source Code (via GitHub)
Version 1.2.5 Source Code (via GitHub)

 
Compatibility
I haven't tested compatibility, feel free to post what browsers this works/doesn't work on.
 
License
The MIT License (MIT)

Edited by Derme, 29 April 2015 - 07:15 AM.

  • 5
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#2 CloudBomb

CloudBomb

    GMC Member

  • GMC Member
  • 475 posts
  • Version:GM:Studio

Posted 13 April 2014 - 07:44 AM

This looks great. Nice job.

I will look at this in the morning and let you know if I run into any fun bugs. :)


  • 0

#3 willomo

willomo

    GMC Member

  • New Member
  • 11 posts

Posted 13 April 2014 - 01:31 PM

Not sure what I've done wrong, but when I create a textbox using <textarea> I can't type anything into it.

 

Be nice if the example showed a few other HTML elements.

 

Fantastic work though! Once I wrap my head around it there'll be a thouseand and one uses for this.


  • 1

#4 Ruub

Ruub

    Finn The Human

  • GMC Member
  • 762 posts
  • Version:GM:Studio

Posted 13 April 2014 - 09:48 PM

I love you. Will try out tomorrow <3


  • 1

#5 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 14 April 2014 - 11:20 AM

Thanks all for the positive support! :)

 

 

Not sure what I've done wrong, but when I create a textbox using <textarea> I can't type anything into it.

 

Be nice if the example showed a few other HTML elements.

 

Fantastic work though! Once I wrap my head around it there'll be a thouseand and one uses for this.

 

 

This is due to the way that the GameMaker canvas steals all the input for itself, I'm looking into how to work around this but no promises.


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#6 Ruub

Ruub

    Finn The Human

  • GMC Member
  • 762 posts
  • Version:GM:Studio

Posted 16 April 2014 - 12:32 PM

Haolaea

 

Working with linked icons and dang, this is hard ;) seems to work pretty well though!

 

Not sure how the <head> and <body> and javascript <script> things work, but that's next stage testing!

 

edit:

Cannot seem to move html id without calling it twice:

htmlid = gmh_canvas_html_add_event();
htmlid = gmh_canvas_html_add_event();

It's odd. Also I found out you work with a different canvas so you ´activate´ a different screen without activating it´s functions. Same with the keys, the new created html casvas absorbs your key input (which can be good xD)

 

edit 2:

Hmm could I use this code?

<A HREF="javascript:javascript:history.go(-1)">Click here to go back to previous page</A>

Edited by Ruub, 16 April 2014 - 06:58 PM.

  • 1

#7 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 19 April 2014 - 04:24 AM

edit:
Cannot seem to move html id without calling it twice:

htmlid = gmh_canvas_html_add_event();
htmlid = gmh_canvas_html_add_event();


EDIT: Can you show me how you are using this code? I'm can't seem to replicate the issue. :/
 

edit 2:
Hmm could I use this code?

<A HREF="javascript:javascript:history.go(-1)">Click here to go back to previous page</A>


This should work:
gmh_canvas_html_add(50, 50, '<a href="" onclick="history.go(-1); return false;"> Link </a>'); 

Edited by Derme, 19 April 2014 - 04:32 AM.

  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#8 Unrival

Unrival

    GMC Member

  • New Member
  • 6 posts
  • Version:GM:Studio

Posted 01 July 2014 - 11:21 AM

Example is not working?


  • 0

#9 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 03 July 2014 - 07:06 AM

Example is not working?

 

Seems fine here, what browser are you using?


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#10 SickAssApe

SickAssApe

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:HTML5

Posted 28 July 2014 - 07:56 AM

 

Example is not working?

 

Seems fine here, what browser are you using?

 

Same here, using Chrome browser.

Found an error message "Uncaught TypeError: undefined is not a function" on line 549 in Chrome console.


  • 0

#11 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 28 July 2014 - 11:30 AM

 

 

Example is not working?

 

Seems fine here, what browser are you using?

 

Same here, using Chrome browser.

Found an error message "Uncaught TypeError: undefined is not a function" on line 549 in Chrome console.

 

 

Thanks for the heads up, Chrome recently removed an API that GameMaker and other APIs relied on for the new audio system. This has caused any GM game that uses the new audio system to stop working, while the demo doesn't use the new audio system the box is still checked.

I only just became aware of this so I'll rebuild all my demos over the next few days, if you use the source and build it with the latest EA version of GameMaker it should still work fine. (let me know if it doesn't)


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#12 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 31 July 2014 - 08:55 AM

Updated example to work in newer versions of Chrome.


  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#13 SickAssApe

SickAssApe

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:HTML5

Posted 19 August 2014 - 02:15 AM

Updated example to work in newer versions of Chrome.

 

Works like a charm!

 

I've been able to put a websocket message system inside the game with the help of this extension.

 

Thank you for this extension!


  • 1

#14 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 19 August 2014 - 09:43 AM

 

Updated example to work in newer versions of Chrome.

 

Works like a charm!

 

I've been able to put a websocket message system inside the game with the help of this extension.

 

Thank you for this extension!

 

 

That's awesome! Good to hear it worked out for you.


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#15 chmod777

chmod777

    GMC Member

  • New Member
  • 7 posts
  • Version:GM:Studio

Posted 20 November 2014 - 03:53 PM

Thanks for this extension. :)

 

With the iframe tag, you can load a html page and show videos (and do many other things I guess). For example :

 

showVideo = gmh_canvas_html_add(0, 0, ' <iframe width="600" height="400" style="border: none;" src="LinkToYourVideo/video1.html"></iframe>');

gmh_canvas_html_show(showVideo);

 

This will load the "video1.html" page which contains a html5 video (http://www.w3schools...html5_video.asp). Works fine on Firefox and Chrome.

You can put the "video1.html" file on the "Included files" of Game Maker. But you can't do it for the video itself, you have to host it directly to your webserver, otherwise the video won't load.

 

!! Seems it doesn't work anymore with the last version of GM Studio.


Edited by chmod777, 24 November 2014 - 07:14 PM.

  • 0

#16 trekkie

trekkie

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 03 December 2014 - 04:19 PM

seems nices, would be great if could get text input for a forum working.

 


Edited by trekkie, 03 December 2014 - 04:34 PM.

  • 0

#17 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 08 January 2015 - 03:01 AM

Sorry for the late replies guys, missed the notification.
 

Thanks for this extension. :)

 

With the iframe tag, you can load a html page and show videos (and do many other things I guess). For example :

 

showVideo = gmh_canvas_html_add(0, 0, ' <iframe width="600" height="400" style="border: none;" src="LinkToYourVideo/video1.html"></iframe>');

gmh_canvas_html_show(showVideo);

 

This will load the "video1.html" page which contains a html5 video (http://www.w3schools...html5_video.asp). Works fine on Firefox and Chrome.

You can put the "video1.html" file on the "Included files" of Game Maker. But you can't do it for the video itself, you have to host it directly to your webserver, otherwise the video won't load.

 

!! Seems it doesn't work anymore with the last version of GM Studio.

 

The extension or being able to use iframes? Both are working for me. (1.4.1499)
 

seems nices, would be great if could get text input for a forum working.

 

YYG are aware of the issue, but haven't done much about it. See this topic from half a year ago and the corresponding Bug report.


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#18 Wo1f_fang77

Wo1f_fang77

    GMC Member

  • New Member
  • 1 posts
  • Version:GM:Studio

Posted 14 January 2015 - 08:54 PM

How do I download this?


  • 0

#19 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 14 January 2015 - 10:55 PM

How do I download this?

Use the GitHub link and on the right there is a "Download Zip" button, click that. :)


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#20 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 13 February 2015 - 11:31 AM

Now available on the GameMaker Marketplace! (Still %100 Free)


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#21 trekkie

trekkie

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 13 February 2015 - 03:26 PM

http://bugs.yoyogame...ew.php?id=14425

 

2015-02-13 12:35 Russell Kay Resolution open => fixed

 

wait will text boxes work now ? anybody try ?


  • 0

#22 tsa05

tsa05

    GMC Member

  • GMC Member
  • 1063 posts
  • Version:GM:Studio

Posted 13 February 2015 - 03:39 PM

:OOOO And I didn't see the email about it! ><

If this works, I owe Russell many cookies.

 

(Here's the workaround I've been using all this time:

Currently using js to add an input textbox with serialized ID, using js to get focus, and then updating textbox's "value" with keyboard_string. It works, but only allows native keyboard to pop up, all character input, and Backspace. Doesn't allow insertion, selecting, copying/pasting)

 

If it's updated in SVN, I assume it'll be in an upcoming EA build~ *fingers crossed*


  • 0

#23 trekkie

trekkie

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 13 February 2015 - 03:53 PM

yea browser_input_capture(enable) is not in the early access yet. hopefully by tomorrow or the end of next week.


Edited by trekkie, 13 February 2015 - 03:53 PM.

  • 0

#24 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 13 February 2015 - 09:59 PM

:OOOO And I didn't see the email about it! ><
If this works, I owe Russell many cookies. <snip>


Many, many cookies.

 

http://bugs.yoyogame...ew.php?id=14425
 
2015-02-13 12:35 Russell Kay Resolution open => fixed
 
wait will text boxes work now ? anybody try ?


yea browser_input_capture(enable) is not in the early access yet. hopefully by tomorrow or the end of next week.


Alright so the feature was just added mere hours ago and it needs to be tested first. Russell has sent me a preview build so I can test it with with Canvas Companion and make sure textboxes are working (Ya! Textboxes). I don't think you'll see it for a few weeks in EA, but it is coming! :biggrin:


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#25 jcoggins

jcoggins

    GMC Member

  • GMC Member
  • 68 posts

Posted 14 February 2015 - 04:40 AM

Where can I find an example of firing an event?

 

It would also be nice if the version in the marketplace had a working example of all the available functions instead of just gmh_canvas_html_add().

 

Nice job though.

 

Jason


  • 0

#26 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 15 February 2015 - 05:26 AM

Where can I find an example of firing an event?

 

It would also be nice if the version in the marketplace had a working example of all the available functions instead of just gmh_canvas_html_add().

 

Nice job though.

 

Jason

Thanks Jason! I'm currently working on getting browser_input_capture(enable) working, once I've done that I'll start working on a full set of demos and documentation over the next few months.


As for a fire event, I believe (it's been awhile since I looked at the code), that it is for use with a JS listener and its function is to artificially trigger said listener.


Edited by Derme, 15 February 2015 - 05:36 AM.

  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#27 trekkie

trekkie

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 17 February 2015 - 03:07 PM

 

Where can I find an example of firing an event?

 

It would also be nice if the version in the marketplace had a working example of all the available functions instead of just gmh_canvas_html_add().

 

Nice job though.

 

Jason

Thanks Jason! I'm currently working on getting browser_input_capture(enable) working, once I've done that I'll start working on a full set of demos and documentation over the next few months.


As for a fire event, I believe (it's been awhile since I looked at the code), that it is for use with a JS listener and its function is to artificially trigger said listener.

 

 

 

sounds like you are going to put alot of work into it, which is great. I know its free now, but I would gladly pay a few quid for 

some good demos and documentation, and i am sure others on the marketplace would.


  • 0

#28 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 19 February 2015 - 12:00 AM

<snip>
sounds like you are going to put alot of work into it, which is great. I know its free now, but I would gladly pay a few quid for 
some good demos and documentation, and i am sure others on the marketplace would.


So I'm still thinking about price at the moment, currently considering raising the price to $3-$5 once the documentation is finished. But the source code will always remain open and free on GitHub, you'll only be paying for the docs & demos.


Also has everyone seen the release notes for the latest EA!? 
 

HTML5

  • Fix for audio groups not playing
  • browser_input_capture() added for toggling whether the game allows other page elements have user input

I still haven't tested everything with it though, please let me know if you run into any issues.
  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#29 trekkie

trekkie

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 19 February 2015 - 03:49 PM

i did a quick test in EA, using your extensions and two forum inputs fields (name and email) it worked well enough for me, bough up native keyboard on ios,andriod,winphone,  which is awesome.


  • 1

#30 trekkie

trekkie

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 25 February 2015 - 01:37 PM

Hey Derme , is there any way to get the html5 elements created to work with a game maker scaling script for example i use jchmtl5 and when i scale the game

objects and buttons move fine but html5 elements like text boxes end up off the canvas.


  • 0

#31 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 25 February 2015 - 11:11 PM

Hey Derme , is there any way to get the html5 elements created to work with a game maker scaling script for example i use jchmtl5 and when i scale the game
objects and buttons move fine but html5 elements like text boxes end up off the canvas.


So I'm not familiar with the inner workings of JCHTML (I do remember reading about it, however I can't find the topic about it on the GMC), but I have an idea that the solution to your problem is something like this.

You could loop though all the HTML elements you've created with GMH and move them with gmh_canvas_html_set_x(id,x) and gmh_canvas_html_set_y(id,y)

It should be as simple as:
 

scale_factor = canvas_width_scaled/canvas_width_original;
position_current = gmh_canvas_html_get_x(id);
position_scaled = position_current * scale_factor;
gmh_canvas_html_set_x(id, position_scaled)

 (But you'd have to do the y as well)


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#32 trekkie

trekkie

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 14 April 2015 - 04:17 PM

Hey Derme, 

 

any advice on on send information entered in a text box with thi?  i can create the form in html, but if i try to do a GET or POST to say php page , will that work ?

 

also hows the docs coming ? i am up for paying for good examples when there out.


Edited by trekkie, 14 April 2015 - 04:17 PM.

  • 0

#33 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 17 April 2015 - 07:16 AM

Alright guys, this one is my bad, I forgot we needed a new function to return the textbox value.

I'll be releasing an update in the next few weeks. If you need the update now, for your project, feel free to PM me and I'll set you up with the pre-release.

 

If anyone else it having issues please let me know, I can't fix what I don't know about and I love hearing feedback (good or bad).

 

 

<snip>

 

also hows the docs coming ? i am up for paying for good examples when there out.

 

 

On hold, currently busy finishing my latest game. Once that's finished (Hopefully in the next few weeks) then I'll have some time to muck around and update GMH.

 


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#34 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 22 April 2015 - 10:11 AM

GMH - Canvas Companion 1.2 - Now Available
 
So I've finished adding the new functions and they should be working, let me know if you find any bugs.

So what's new?

  • gmh_canvas_html_get_value(id); - Gets the value from a HTML object like a textbox, be careful to use this function only with objects that have values
  • gmh_canvas_html_set_value(id, value); - Sets the value from a HTML object like a textbox, be careful to use this function only with objects that have values
  • New demo to show you how to get started with textboxes

Download Source Code (via GitHub)
GameMaker Marketplace

 

Example of new code in action:

///Create Textbox
_id = gmh_canvas_html_add(100, 100, '<input type="text" name="txtExample" value="My Value">');

// Then you can change the text the textbox is displaying with:
gmh_canvas_html_set_value(_id, "Pizza");

Edited by Derme, 22 April 2015 - 10:19 AM.

  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#35 mudora23

mudora23

    GMC Member

  • GMC Member
  • 232 posts
  • Version:GM:Studio

Posted 22 April 2015 - 11:54 PM

I have been waiting for this for so long. Thank you so much. it seems like providing a better way to work on foreign language as well. Gonna test it further. It's been working great so far!

 

P.S. This extension doesn't seem to work with WebGL, right?


Edited by mudora23, 23 April 2015 - 03:48 AM.

  • 1

#36 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 23 April 2015 - 06:41 AM

I have been waiting for this for so long. Thank you so much. it seems like providing a better way to work on foreign language as well. Gonna test it further. It's been working great so far!

 

P.S. This extension doesn't seem to work with WebGL, right?

 

Thanks! As for WebGL, I can't see why it wouldn't work, if you PM me a basic sample of a broken WebGL & GMH project I'm happy to look into it though.


  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#37 mudora23

mudora23

    GMC Member

  • GMC Member
  • 232 posts
  • Version:GM:Studio

Posted 24 April 2015 - 01:31 PM

 

I have been waiting for this for so long. Thank you so much. it seems like providing a better way to work on foreign language as well. Gonna test it further. It's been working great so far!

 

P.S. This extension doesn't seem to work with WebGL, right?

 

Thanks! As for WebGL, I can't see why it wouldn't work, if you PM me a basic sample of a broken WebGL & GMH project I'm happy to look into it though.

 

 

My bad! I forgot the fact that we can't use runtime font with WebGL. It just freezes the whole game whenever I try. So the default font wouldn't work. I added a new font and it is working now! Thank you so much! :D


Edited by mudora23, 24 April 2015 - 01:32 PM.

  • 0

#38 mudora23

mudora23

    GMC Member

  • GMC Member
  • 232 posts
  • Version:GM:Studio

Posted 24 April 2015 - 05:25 PM

I have a question, how can you switch to the game to capture the input again? (i.e. browser_input_capture(true); ) I can only think of some condition like string_length(str) >= 5 which is not practical at all :(

 

 

---

 

P.S. I solved the problem. In case someone is wondering ...

 

 

// I added a new function in javascript

function gmh_canvas_html_active_element() {

    return document.activeElement.tagName;
}

 

/// Textbox looks like this

_id = gmh_canvas_html_add(100, 100, '<input type="text" name="txtExample" value="My Value" onkeydown="if (event.keyCode == 13) blur()">'); 

 

// Step Event

if(gmh_canvas_html_active_element() == "INPUT") browser_input_capture(false);

else browser_input_capture(true);

 


Edited by mudora23, 26 April 2015 - 01:31 AM.

  • 1

#39 trekkie

trekkie

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 25 April 2015 - 12:58 PM

Hey Derme

 

One thing you should considered adding in future builds if you create a second object that calls gmh_initiate (or if you for example leave the room with the object, and then re-enter it, causing the object to be created again), then you get an error:

Uncaught HierarchyRequestError: Failed to execute 'insertBefore' on 'Node': The new child element contains the parent.
 
As a workaround, I add this, to ensure gmh_initiate only runs once, but maybe there should be a gmh_destroy function?
 
var ran_once=0

// Rest of stuff

function gmh_initiate() {
 if (ran_once==0)
 {
 canvas_html.setAttribute("id","canvas_html");
 canvas_html.style.position = "absolute";
 canvas_html.style.left = "0px";
 canvas_html.style.top = "0px";
 canvas.parentNode.insertBefore(wrapper, canvas);

 wrapper.appendChild(canvas);
 wrapper.appendChild(canvas_html);
 }
 ran_once=1;
}

Edited by trekkie, 25 April 2015 - 01:00 PM.

  • 1

#40 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 26 April 2015 - 01:35 AM

I have a question, how can you switch to the game to capture the input again? (i.e. browser_input_capture(true); ) I can only think of some condition like string_length(str) >= 5 which is not practical at all :(
 
 
---
 
P.S. I solved the problem. In case someone is wondering ...
 
 
<snip>

 
I was going to suggest using a HTML textbox for a "submit" button, however your solution is much cleaner. Do you mind if I add this to the next version of GMH?
 
 

Hey Derme
 
One thing you should considered adding in future builds if you create a second object that calls gmh_initiate (or if you for example leave the room with the object, and then re-enter it, causing the object to be created again), then you get an error:
Uncaught HierarchyRequestError: Failed to execute 'insertBefore' on 'Node': The new child element contains the parent.
 
As a workaround, I add this, to ensure gmh_initiate only runs once, but maybe there should be a gmh_destroy function?
 
 
<snip>

Thanks for the suggestion! It'll be in the next version.


P.S You guys are amazing.

Edited by Derme, 26 April 2015 - 01:37 AM.

  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#41 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 29 April 2015 - 07:06 AM

GMH - Canvas Companion 1.2.5 - Now Available
 
So I've finished adding the new functions you that were suggested and they should be working, let me know if you find any bugs.

So what's new?

  • gmh_canvas_html_active_element() - This returns the type of HTML element that is currently active allowing you to dynamically toggle browser_input_capture(true); (Thanks mudora23)
  • gmh_canvas_html_set_checked(id, value) - This sets the value of a checkbox; (Thanks Trekkie)
  • gmh_canvas_html_get_checked(id) - This gets the value of a checkbox
  • The textbox demo has been updated to reflect the changes
  • An initialisation check has been added to prevent errors with gmh_initiate

Download Source Code (via GitHub)
GameMaker Marketplace


  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#42 mudora23

mudora23

    GMC Member

  • GMC Member
  • 232 posts
  • Version:GM:Studio

Posted 01 June 2015 - 10:19 PM

 

I have a question, how can you switch to the game to capture the input again? (i.e. browser_input_capture(true); ) I can only think of some condition like string_length(str) >= 5 which is not practical at all :(
 
 
---
 
P.S. I solved the problem. In case someone is wondering ...
 
 
<snip>

 
I was going to suggest using a HTML textbox for a "submit" button, however your solution is much cleaner. Do you mind if I add this to the next version of GMH?

 

Sure! I am glad I could help  :lol:


  • 0

#43 Chaos Design

Chaos Design

    2D/3D Graphic Artist

  • GMC Member
  • 254 posts
  • Version:GM:HTML5

Posted 20 June 2015 - 04:43 PM

Would it be possible to create interactive html5 videos for the web with this?


  • 0

My GM Projects:

games11.png

                              

                     


#44 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 21 June 2015 - 11:49 AM

Would it be possible to create interactive html5 videos for the web with this?

It's most certainly possible, however not directly supported - some extra JS coding would be required.


  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png