Eran,

In Jmol scripting, just getting the number:

   x = {selected}.size;

In JavaScript, getting the number:

var x = jmolEvaluate("{selected}.size"))

In Jmol there isn't a "selectCallback" so if the user is selecting by 
using the menu, that's not immediately available. But there is a 
pickCallback, which  fires when atoms are picked. So if you are setting 
the selection by  picking,  you should be able to piggy back on the 
pickCallback.

The following Jmol script displays the number of selected atoms in the 
upper left corner of the applet when an atom is picked:

set picking select;
set echo top left;
set pickcallback "jmolscript:echo %{{selected}.size} atoms selected";

No JavaScript necessary!

However, you can use the messageCallback for this, because it fires 
after any selection is made (among other things). The following runs the 
JavaScript function showSelected each time a selection is made.

Jmol:

set messageCallback "showSelected";


JavaScript:

function showSelected() {
  alert (jmolEvaluate("{selected}.size")))
}

Although it fires too often, even when atoms are not selected, that's 
probably OK if you are just putting the number in a box.

Bob


Eran Hodis wrote:

>What would be the best way to get the total number of atoms currently  
>selected in Jmol?
>
>I'm using the applet on a webpage, and I'm looking to have a small  
>box that constantly displays the total number of atoms currently  
>selected.
>
>Is it possible to receive some sort of notification each time the  
>amount of atoms selected changes so that the number I display can be  
>updated?
>
>Best,
>Eran Hodis
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by: Splunk Inc.
>Still grepping through log files to find problems?  Stop.
>Now Search log events and configuration files using AJAX and a browser.
>Download your FREE copy of Splunk now >> http://get.splunk.com/
>_______________________________________________
>Jmol-users mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/jmol-users
>  
>


-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get. 

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to