>>  http://jmol.sourceforge.net/tracedemo
>>
>>With JmolAppletControl buttons, no JavaScript is necessary.
>>Now, I have *not* tried this on OSX but I think it will work.
>
> All works fine.
I have received three reports from people that the JmolAppletControl
buttons function properly on OS X. That is good news.


> How did you bypass liveconnect?
For those who are not familiar with the term 'LiveConnect' ...
LiveConnect involves communications between JavaScript and Java. It
allows you to write JavaScript in an html page and call functions inside
Java applets. You can, for example, use links such as

  <a href="javascript:document.jmol.script("background blue")>blue</a>

or buttons such as

  <form>
    <input type=button value='Blue'
           onClick='document.jmol.script("background blue")>
  </form>

Unfortunately, you cannot do this on MacOSX because none of the browsers
support LiveConnect.


The JmolAppletControl uses a different mechanism. It is itself a Java
applet, defined as follows:

  <applet name=blueButton code=JmolAppletControl archive=JmolApplet.jar
          width=50 height=20 mayscript>
          <param name=type     value=button>
          <param name=label    value='Blue'>
          <param name=target   value=jmol>
          <param name=script   value='background blue'>
  </applet>

Fortunately, applets can communicate with each other without involving
JavaScript. So, a JmolAppletControl can send a script directly to a target
applet on the same page without using LiveConnect. (There *are* some
caveats, but that will be left for another day.)

For those of you who have written chime pages, it is very similar to the
use of chime buttons ... the buttons are part of the plug-in and one
instance of the plug-in can communicate with other instances of the
plug-in without involving JavaScript.

In fact, the JmolAppletControl was written to facilitate converting
existing chime html pages to use the JmolApplet. Jmol provides a perl
script (chime2jmol.pl) to facilitate/automate this conversion. Instances
of chime buttons are replaced with the JmolAppletControl.

> Is not  mayscript a liveconnect feature?
An astute observation! ... yes it is.

The short answer is ... in this simple case, it is not needed. But in more
complicated html pages it *is* required. So, in the spirit of promoting
clean and consistent coding practices, I included it.

A little more background on 'mayscript' for those who are interested:

'mayscript' is an optional attribute to the <applet> tag in html. It is
not very well know because it doesn't get used very much. Its purpose is
to tell LiveConnect that the applet *may* *script* ... that is, the java
applet may call javascript.

By default, the html page writer can use JavaScript to invoke Java methods
inside an applet. But, the html page writer needs to give explicit
'mayscript' permission to an applet to allow the *applet* to call
JavaScript code.

When would an applet want to invoke JavaScript code? For example, a
JmolAppletControl can specify a 'buttonCallback', which is a piece of
javascript which will be called before the associated script is run and
after the script completes.

  <script>
    function buttonPressed(buttonName, hasExecuted) {
      var hasOrHasNotExecuted;
      if (hasExecuted)
        hasOrHasNotExecuted = ' has executed';
      else
        hasOrHasNotExecuted = ' has not executed';
      alert(buttonName + hasOrHasNotExecuted);
    }
  </script>

  <applet name=blueButton code=JmolAppletControl archive=JmolApplet.jar
          width=50 height=20 mayscript>
          <param name=type     value=button>
          <param name=label    value='Blue'>
          <param name=target   value=jmol>
          <param name=script   value='background blue'>
          <param name=buttonCallback value=buttonPressed>
  </applet>

(WARNING! I have not tested *any* of this html code ... but I think it is
pretty close ;-)

Miguel





-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Jmol-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to