With this function you can create a custom, clickable, icon that acts as a "button" outside of the game canvas, but within the browser window itself. The function will return an id value which must be stored in a variable to be used in all further button functions that reference the new icon. This function is very useful to prevent the browser creating a pop-up window when clicking on the button as it is all done through GameMaker Studio 2 itself.
Valid targets are:
Target Description _blank Opens the linked document in a new window or tab. _self Opens the linked document in the same frame as it was clicked (this is default). _parent Opens the linked document in the parent frame. _top Opens the linked document in the full body of the window.
Valid parameters are:
Parameters Description 'height=[px]' The height of the window, with the minimum value being 100. 'width=[px]' The width of the window, with the minimum value being 100. 'left=[px]' The left position of the window. 'top=[px]' The top position of the window (IE only). 'location=[boolean]' Whether or not to display the address field (default is 1). 'menubar=[boolean]' Whether or not to display the menu bar (default is 1). 'resizable=[boolean]' Whether or not the window is resizable (default is 1). 'scrollbars=[boolean]' Whether or not to display scroll bars (default is 1). 'status=[boolean]' Whether or not to add a status bar (default is 1). 'titlebar=[boolean]' Whether or not to display the title bar. This is ignored unless the calling application is an HTML Application or a trusted dialog box (default is 1); 'toolbar=[boolean]' Whether or not to display the browser toolbar (default is yes).
It is also worth noting that if the URL argument you pass in is the name of a script (ie: it doesn't start with "http://") AND the script is called gmcallback_* then you can get direct feeds into an html5 event. GameMaker Studio 2 function names are not obfuscated if they begin with gmcallback_.
clickable_add(x, y, tpe, url, target, params);
|x||The x position within the window.|
|y||The y position within the window.|
|tpe||The texture page entry for the sprite to be used (use sprite_get_tpe).|
|url||The URL (website address) to link to, or the script to be run.|
|target||This is the target area to open the URL in (see description).|
|params||The various parameters for the icon (see description).|
home_but = clickable_add(32, 32, sprite_get_tpe(spr_MS_Home, 0), "http://macsweeney_games.com", "_blank", "width=700, height=500, menubar=0, toolbar=0, scrollbars=0");
The above code creates a clickable DOM icon at the position (32, 32) of the page that the game canvas is running on. The icon uses the sprite referenced from the texture page as "spr_MS_Home" and when clicked the icon will open a new window for the specified URL and with the defined properties for that window.