Kekule.js icon indicating copy to clipboard operation
Kekule.js copied to clipboard

onChange for Kekule Composer?

Open richardoptibrium opened this issue 2 years ago • 1 comments

I'm looking for a way to set an onChange (or similar) event with the widget, there must be something similar in the code for example that enables the undo function?

I'd like to be able to set the smiles string in an external text box every time the design changes affecting the smiles string. Would really appreciate any help on this, I'm using the kekule composer widget.

Thanks in advance!

richardoptibrium avatar Jun 15 '22 14:06 richardoptibrium

Quite sorry that I hadn't notice this issue so far... The editObjsUpdated event can be used here, e.g.:

composer.getEditor().on('editObjsUpdated', function(e){
  let mol = Kekule.ChemStructureUtils.getTotalStructFragment(composer.getChemObj());
  if (mol)
    let smiles = Kekule.IO.saveMimeData(mol, 'chemical/x-daylight-smiles');
});

partridgejiang avatar Jul 17 '22 05:07 partridgejiang