partridgejiang / Kekule.js

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

[question] Activating specific composer buttons from script? #127

Open cleblond opened 5 years ago

cleblond commented 5 years ago

Is it possible to activate/toggle a composer button from js. For example how would I make the bond tool the active tool?

partridgejiang commented 5 years ago

The following code can do the work, though a little inconvenient. Direct and clear APIs may be added in the future.

// every button in composer is associated with a special action object, find the one linked with bond button:
var action = composer.getActionMap().get(composer.getCompActionClass('bond'));
// execute the action
action.execute();