jsme-editor / jsme-editor.github.io

73 stars 19 forks source link

Resetting of highlight via command seems broken #31

Closed Phil-DS closed 1 month ago

Phil-DS commented 1 year ago

From looking at the documentation the following should remove the highlights from the first molecule on the drawer

resetHighlight() {
    jsmeApplet.resetAtomColors(1)
    jsmeApplet.resetBondColors(1)
  }

However, this seems to fail. Tried to reset it by overriding the highlights, but it doesn't work either (A grey highlighting overlaying the entire molecule, but the original blue highlights remain).

jsme-editor commented 1 year ago

Unfortunately, I cannot reproduce the issue you described. My test file is https://jsme-editor.github.io/dist/JSME_atom_highlight_demo.html . jsmeApplet.resetAtomColors(1) should reset the background colors of the atoms of the first molecule.

I changed this line in the test HTML file to use index of 1 instead of 0::

<button type="button" onclick='jsmeApplet.resetAtomColors(1);'>Reset atom colors</button>

And it worked as expected.

Phil-DS commented 1 year ago

I tried that, but it only works with highlights set via the setAtomBackground command. If you set them via the highlighter, it fails to remove them. If you set some with the highlighter and some via setAtomBackground, only the setAtomBackground ones are removed, and the highlighter ones remain.

This was also tested with the page above.

jsme-editor commented 1 year ago

Screenshot from 2023-02-13 22-00-15

If I set one atom background color using the drop down color menu, clicking on the "Reset atom colors" button does not reset the color of this atom. Is this what you mean?

Phil-DS commented 1 year ago

Yes, that's what I mean.

jsme-editor commented 1 year ago

The upcoming version of JSME will have a new function, resetAtomMarks() , that can be used to reset the marks of the atoms that have been set with the drop down color menu (starting options: marker,markermenu). Similarly, there will a new function called resetBondMarks(). Screenshot from 2023-02-22 21-54-25

Notes:

The atom marker can be used to mark an atom with only one color. Atom marks can be exported and imported as atom maps in SMILES or MOLFILE . Atom background colors can be mixed (more than one color per atom, e.g. 1,3,1,4,1,5,1,6). They cannot be exported or imported. There is no GUI element to set the background colors.

jsme-editor commented 2 months ago

A new version of JSME has been released. Could you try and check if the proposed solution works for you?

Phil-DS commented 1 month ago

Works for my scenario. Thanks!