partridgejiang / Kekule.js

A Javascript cheminformatics toolkit.
http://partridgejiang.github.io/Kekule.js
MIT License
250 stars 61 forks source link

What is the best way to be notified when an 'edit' action has been completed in the viewer? #140

Closed robotoer closed 5 years ago

robotoer commented 5 years ago

Is there a callback or something that can trigger code after pressing the edit button on the viewer toolbar, making changes in the composer dialog, and pressing the 'OK' button?

partridgejiang commented 5 years ago

A simple way is to detect the viewer widget's load event, which will be invoked when a new or modified chem object has been reloaded in the viewer:

viewer.on('load', function(e){
  console.log('Object modified', e.obj);
});

In the latest dist, event editingDone can also be used here (see commit ab6b6c6c1c69861d53dad147a1f04dd2189be1ae).

robotoer commented 5 years ago

Perfect! Thanks a bunch @partridgejiang