On 11/21/2014 01:53 PM, Robert Hanson wrote:
> Rolf, you mean you want to access the point where the hover is over? The
> most recent atom index hovered over is _atomhovered, so you can use that
> and, within your function:
>
> var a = {atomIndex=_atomhovered}
> print a
> print a.xyz
>
> etc.
>
> There is no callback when the hover is released. I suppose you could set a
> timeout for that.
>
Bob, thank you for the suggestion.
Generally it seems to work with the timeout.
But there seems to be a problem with finishing timeouts.
The code below works if I stay only very shortly above an atom.
But when I stay longer, at first the 'timeout "hoverEnd" off' command
seems to work (see results below; only 'start' calls and no 'end' calls)
but then 'start' and 'end' calls start alternating very fast and
regularly. (The 'ends' come much faster than every two seconds.)
---- Code -------------------------
var lastAtomIndexHovered = -1;
var lastHoverUnfinished = false;
function hoverAction(action) {
timeout "hoverEnd" off;
var switchOff = false;
var currentSelection = {selected};
var currentBondmode = bondModeOr;
set bondModeOr false;
if (action == "end") {
if (lastHoverUnfinished) {
switchOff = true;
}
} elseif (action == "start") {
if (lastHoverUnfinished) {
if (lastAtomIndexHovered != _atomhovered) {
switchOff = true;
}
}
}
print "action=" + action + " switchOff=" + switchOff + "
lastHoverUnfinished=" + lastHoverUnfinished + " lastAtomIndexHovered="
+ lastAtomIndexHovered + " _atomhovered=" + _atomhovered;
if (switchOff) {
if (lastAtomIndexHovered >= 0) {
select atomindex=@lastAtomIndexHovered OR
connected(atomindex=@lastAtomIndexHovered);
color halo yellow;
halo off;
color bonds translucent 4;
}
lastAtomIndexHovered = -1;
lastHoverUnfinished = false;
}
if (_atomhovered >= 0 && action == "start") {
lastAtomIndexHovered = _atomhovered;
lastHoverUnfinished = true;
select atomindex=@lastAtomIndexHovered OR
connected(atomindex=@lastAtomIndexHovered);
color halo cyan;
halo on;
color bonds translucent 0;
timeout "hoverEnd" 2.0 "hoverAction('end')";
}
select @currentSelection;
set bondModeOr @currentBondmode;
}
set hoverCallback "jmolscript: hoverAction('start');";
---- Results --------------------------
action=start switchOff=false lastHoverUnfinished=false
lastAtomIndexHovered=-1 _atomhovered=20
action=start switchOff=false lastHoverUnfinished=true
lastAtomIndexHovered=20 _atomhovered=20
action=start switchOff=false lastHoverUnfinished=true
lastAtomIndexHovered=20 _atomhovered=20
action=start switchOff=false lastHoverUnfinished=true
lastAtomIndexHovered=20 _atomhovered=20
action=start switchOff=false lastHoverUnfinished=true
lastAtomIndexHovered=20 _atomhovered=20
action=end switchOff=true lastHoverUnfinished=true
lastAtomIndexHovered=20 _atomhovered=20
action=start switchOff=false lastHoverUnfinished=false
lastAtomIndexHovered=-1 _atomhovered=20
action=end switchOff=true lastHoverUnfinished=true
lastAtomIndexHovered=20 _atomhovered=20
action=start switchOff=false lastHoverUnfinished=false
lastAtomIndexHovered=-1 _atomhovered=20
action=end switchOff=true lastHoverUnfinished=true
lastAtomIndexHovered=20 _atomhovered=20
action=start switchOff=false lastHoverUnfinished=false
lastAtomIndexHovered=-1 _atomhovered=20
action=end switchOff=true lastHoverUnfinished=true
lastAtomIndexHovered=20 _atomhovered=20
--------------------------------
Regards,
Rolf
--
Rolf Huehne
Postdoc
Leibniz Institute for Age Research - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany
Phone: +49 3641 65 6205
Fax: +49 3641 65 6210
E-Mail: [email protected]
Website: http://www.fli-leibniz.de
Scientific Director: Prof. Dr. K. Lenhard Rudolph
Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Dennys Klein
VAT No: DE 153 925 464
Register of Associations: No. 230296, Amtsgericht Jena
Tax Number: 162/141/08228
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users