view Platforms/Wasm/default-library.js @ 509:1b9973905e15 bgo-commands-codegen

Fix to use js callbacks attached to 'window' + dummy changes in cmake files
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 06 Mar 2019 10:57:02 +0100
parents 7105a0bad250
children 70992b38aa8a
line wrap: on
line source

// this file contains the JS method you want to expose to C++ code

mergeInto(LibraryManager.library, {
  ScheduleWebViewportRedrawFromCpp: function(cppViewportHandle) {
    window.ScheduleWebViewportRedraw(cppViewportHandle);
  },
  CreateWasmViewportFromCpp: function(htmlCanvasId) {
    return window.CreateWasmViewport(htmlCanvasId);
  },
  // each time the StoneApplication updates its status, it may signal it 
  // through this method. i.e, to change the status of a button in the web interface
  UpdateStoneApplicationStatusFromCppWithString: function(statusUpdateMessage) {
    var statusUpdateMessage_ = UTF8ToString(statusUpdateMessage);
    window.UpdateWebApplicationWithString(statusUpdateMessage_);
  },
  // same, but with a serialized message
  UpdateStoneApplicationStatusFromCppWithSerializedMessage: function(statusUpdateMessage) {
    var statusUpdateMessage_ = UTF8ToString(statusUpdateMessage);
    window.UpdateWebApplicationWithSerializedMessage(statusUpdateMessage_);
  }
});