node-webkit invoke download action doesn't work

0 favourites
  • 8 posts
From the Asset Store
11 loops of RPG, chiptune/8-bit music. Suitable for any pixel art game.
  • Hi,

    I am trying to download a screenshot of the canvas. On the preview it works well, but when exported to nodekit I have problems.

    If i minify, instead of a download popup, I get a new "modal" window opened with the contents i want to download. The pop-up window doens't allow doing anything like ctrl-s for save or right mouse click for save as.

    If i don't minify, i get a pop-up window for a split of a second, that then disappears, removing the "goto" shows the captured image in the window "ontop" of the original window (i can see buttons the original window includes).

    all in all, its weird behavior,

    any suggestions would be much appreciated,


  • I wouldn't expect it to work: the normal download UI and right-click menus are all part of the browser UI. Node-webkit is not quite a real browser, just a browser engine with the UI missing so it looks like a native app.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I see. Thanks.

    I noticed that nodekit supports file save. Can it save CanvasSnapshot (non text files)?

  • I noticed that node-webkit save, saves a base64 string -- so I guess I would need to translate this back into a jpg image, somehow, from the outside.

  • Ashley, any chance that node-webkit could support saving a canvas snapshot as an jpg or png -- or is this a limitation imposed by node-webkit itself.

  • This is not supported right now, currently node-webkit can only save text files.

  • Hi Ashley,

    OK, so I solved it with some Javascript injected with the browser, and a tailored javascript call as follows:

    (Its pretty basic. It's too bad that its not supported "natively" in C2 in the node-webkit plugin, but since I am new to javascript, it took me a bit to stich together, and I feel my solution is rather brittle).

    In C2:

    set varCanvas = right(CanvasSnapshot,len(CanvasSnapshot)-23)

    Execute JavaScript varScript & "; me( 'c:\\results\\file99.jpg', '" & varCanvas & "');"

    and javascript I've loaded in the varScript variable:

    function me(name, canvas) {

    var fs = require('fs');

    var img = new Buffer(canvas, encoding='base64');

    fs.writeFile(name, img, function(err) {

    // if(err) {

    // document.write("<p>");

    // document.write(err);

    // document.write("</p>");

    // } else {

    // document.write("<p> The file was saved!</p>");

    // }





  • Can you post a CAPX of this please ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)