From: Alex Richards (boyilovecollege_at_pacific.net)
Date: Wed Jun 26 2013 - 11:13:33 CDT

Forked from a previous thread- "Atom Selection & List Generation". This
isn't a question, but rather a solution to the problem encountered in
the other thread with the subject changed to reflect the relevant issue.

The problem was in attempting to use the Tcl callbacks in VMD,
particularly the ::vmd_pick_event and ::vmd_pick_atom global variables.
Upon starting VMD and opening the TkConsole, issuing the following
commands resulted in the output:

> info exists ::vmd_pick_event
0
> puts $::vmd_pick_event
can't read "::vmd_pick_event": no such variable

While trace would still tie a proc to the variable that didn't exist,
nothing would happen when an atom was "picked".

Here was my problem: I was looking at the Terminal output which, when an
atom is clicked on regardless (mostly) of the mouse mode, would spit out
a bunch of "Info)" lines on the atom such as moleculeid, name, type,
index, resid, etc. Preceding that information was the line "Info) picked
atom:", which lead me to believe I had picked the atom even if I was in
a mode such as Query or Center. However, when in Pick mode, there is an
extra line at the end of the Terminal output which says "Info) User
Pick: mol# atom:#".

Once an atom has been "picked" in Pick mode, it appears that the
::vmd_pick_{event,atom} variables (among others, I'm sure) are created,
but not before. The previous TkConsole commands post-Pick mode picking give:

> info exists ::vmd_pick_event
1
> puts $::vmd_pick_event
1

In this way, the behaviour of trace makes sense - you can set the
callback beforehand so it should run when the variable is finally created.

So, to summarize, when picking, pick only in Pick mode, otherwise the
atoms aren't picked even though the Terminal output says that you picked
an atom.