partridgejiang / Kekule.js

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

Question: setting autoSwitchBondOrder #213

Open cleblond opened 3 years ago

cleblond commented 3 years ago

I was looking into making a controller that cycles bond order when I click on a bond. I came across autoSwitchBondOrder and was wondering how I set this to true.

partridgejiang commented 3 years ago

Hi @cleblond, it's a long-forgotten property which can not work properly for a long time, :(. Thanks for revealing it and I have make some efforts to let it run again in the latest dist files. You can turn it on by:

composer.getIaController('MolBondIaController').setAutoSwitchBondOrder(true);

After that, the original single bond tool can be used on existing bond to switch between single/double/triple orders (similar to the behavior of ChemDraw).

cleblond commented 3 years ago

I updated to latest dist but am getting the following error.

Cannot read property 'setAutoSwitchBondOrder' of undefined.

This is what I tried

var composer = Kekule.Widget.getWidgetById('composer');
composer.getIaController('MolBondIaController').setAutoSwitchBondOrder(true);
partridgejiang commented 3 years ago

Sorry that I have made a mistake, :(, the code should be:

composer.getEditor().getIaController('MolBondIaController').setAutoSwitchBondOrder(true);