Accessing MarvinSketch events in a web application

User 173254b396

25-01-2008 10:27:59

Hi,





Is there a simple way to access he MarvinSketch applet's events from a web application? I am particularly interested in onChange event.





Cheers, Péter

ChemAxon 7c2d26e5cf

27-01-2008 12:45:11

MarvinSketch applet can invoke JavaScript method by property change event, just switch on notification (set "listenpropertychange" parameter to "true"). Please see its documentation for more details.


http://www.chemaxon.com/marvin/help/developer/sketchman.html#parameters.listenpropertychange

User 173254b396

28-01-2008 13:25:59

Hi Tamás,





I tried to use the modified code example but it does nothing for me:








function propertyChange(prop) {


if (prop == "mol")


{


document.getElementById("submit").disabled=false;


}


}


.


.


.


.





msketch_name = "MSketch";


msketch_mayscript=true;


msketch_begin("../marvin", 400, 400);


msketch_param("preload", "MolExport,GraphInvariants,Parity");


//msketch_param("detach", "hide,size=440x440");


msketch_param("listenpropertychange","true");


msketch_param("undetachByX", "false");


msketch_param("menubar", "true");


msketch_param("background", "");








Péter

ChemAxon 7c2d26e5cf

28-01-2008 13:46:39

Please see the following example: Listen PropertyChangeEvents in applet


In your code, the condition is wrong. prop == "mol" condition will never be true. The value of the prop object follows this syntax:


Code:
<propertyname>=<propertyvalue>

User 173254b396

29-01-2008 08:59:00

Is this working in older Marvin versions (4.1.13), or just in Marvin 5.0? I tried to set your example locally with version 4.1.13 with no success.

ChemAxon 7c2d26e5cf

29-01-2008 09:12:17

No, it is a new feature that is available since 5.0.

ChemAxon 7c2d26e5cf

29-01-2008 09:23:56

If you use an older Marvin version, I can recommend you to use the molLoaderFinishedEvent applet parameter. You can not listen all changes on the molecule with this solution. But it can help you to control the loading of a new molecule into the applet (invoked when molecule loading process is completed).

User 870ab5b546

08-02-2008 20:44:01

Can I set a MarvinSketch display parameter from a JavaScript function? I want to turn atomNumbersVisible on or off depending on what a user selects from a pulldown menu. I am using Marvin 4.1.13.

ChemAxon 7c2d26e5cf

13-02-2008 11:00:20

No, there is no way to control the mentioned display property from JavaScript.


But we will investigate how to improve controlling display options of the MarvinSketch applet from JavaScript.

User 870ab5b546

13-02-2008 13:48:22

Tamas wrote:
No, there is no way to control the mentioned display property from JavaScript.
Bummer.
Tamas wrote:
But we will investigate how to improve controlling display options of the MarvinSketch applet from JavaScript.
Thanks. It would be helpful for integrating Marvin into Web apps with other kinds of functionality.