Hi,

I'm clearly not reading the documentation correctly and I'm missing something.  
I want to use the JSmol callback functionality. What am I doing wrong?

Thanks,

--Chuck

My javascript:

    function init_jsmol(state) {

            // … other initialization

            Jmol.setXHTML(model.ids.id_jsmol);

            var Info = {};
            Info.script = session.modelControl.getActiveScript(state);
            Info.j2sPath = model.jsmol.j2sPath;
            Info.disableInitialConsole = true;
            Info.disableJ2SLoadMonitor = true;

            jmolObject = Jmol.getApplet(model.ids.id_jsmol, Info);

            // … other initialization
    }

    function myMessageCallback(one, two) {
        console.info("I'm in myMessageCallback: " + one);
        console.info("I'm in myMessageCallback: " + two);
    }

    function getJSmolInfo(state) {  // called from another part of my code.
        try  {
            console.info("getJSmolInfo entry");

            script(";set messageCallback 'myMessageCallback';");
            script(";define chucksel '[ALA]1:A.O or [ALA]1:A.C'; select 
chucksel; color atoms pink;");
            script("message 'hi ho';");

            console.info("getJSmolInfo exit");
            return Jmol.getPropertyAsArray(jmolObject, "orientationInfo");
        } catch (err) {
            console.info("ERR getJSmolOrientationInfo xxx");
            console.info(err);
        }
        return null;
    }

    function script(script) {
        try  {
            jmolObject._script(script);
        } catch (err) {
            console.info("ERR scriptWait");
            console.info(err);
        }
    }

What I see:  the Alanine that I loaded has the A.O and A.C colored pink.  I 
also see the "orientationInfo" when I look at the return from getJSmolInfo.  
The "state" argument to getJSmolInfo is for later use.

What I didn't see: "hi ho" in the console or any evidence that 
myMessageCallback is called.

Chrome Console:

getJSmolInfo entry 
jsmolControl.js:89<http://localhost:8002/StarBiochem/sb_controller/jsmolControl.js>
getJSmolInfo exit 
jsmolControl.js:93<http://localhost:8002/StarBiochem/sb_controller/jsmolControl.js>
exec _jsmol loadClazz null -- OK 
VM592:250<chrome-devtools://devtools/bundled/devtools.html?dockSide=bottom&toolbarColor=rgba(230,230,230,1)&textColor=rgba(0,0,0,1)>
exec _jsmol start applet null -- OK 
VM592:250<chrome-devtools://devtools/bundled/devtools.html?dockSide=bottom&toolbarColor=rgba(230,230,230,1)&textColor=rgba(0,0,0,1)>
event.returnValue is deprecated. Please use the standard event.preventDefault() 
instead. 
VM592:110<chrome-devtools://devtools/bundled/devtools.html?dockSide=bottom&toolbarColor=rgba(230,230,230,1)&textColor=rgba(0,0,0,1)>
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to