Graphics.WritingACustomPickFunctionality - lordmundi/wikidoctest GitHub Wiki

Writing a Custom Pick Functionality

« Pixelstream Plugin | EDGE User’s Guide | Creating multi-headed displays »

You may have noticed that you can right-click on the view and choose an option called "Pick Model to Edit". This will then let you click on a node in the scene and it will pull up the node edit dialog for that particular node.

Pick Model to Edit
The label that appears when EDGE is in "pick model to edit" mode.

This functionality of graphically selecting a node can sometimes be required for a custom application. This page tries to document how you might extend EDGE to do this.

Tcl commands available

There are a few tcl commands at your disposal for writing a custom pick. The first is:

doug.cmd pick

This returns the name of the node that is currently under the mouse cursor, or empty string ("") if there is nothing there.

You may alternatively want something that calls a tcl procedure as the mouse is moved over various nodes (as you can see happening in the GUI when you do a "Pick Model to Edit"). In this case, you add a callback that will call the tcl procedure you specify as the mouse moves over a new node:

doug.callback add pick -tags SOME_TAG { myscript }

In this case, the procedure or tcl code specified in myscript will be called any time a new node is moved over by the mouse. It will also return empty string whenever the mouse is moved from a node to empty space. The tag is important because you will want to delete this ongoing callback at some point. You can do that with:

doug.callback delete SOME_TAG

In this callback, you may be wondering how to get the name of the node out that the mouse is over. To do that, call:

doug.cmd getnode

This command is only meant to be used inside the pick callback, but it will return the name of the node (or empty string) that the mouse is over. For example, to have the console output the names of the nodes as I drag the mouse around, I might do the following in my command console:

(edge) % doug.callback add pick -tags MYPICK { puts "Mouse is over [doug.cmd getnode]" }
Mouse is over PROGRESS_M
Mouse is over ATV_REF
Mouse is over 
Mouse is over ATV_REF
Mouse is over 
Mouse is over ATV_REF
Mouse is over 
Mouse is over GAMMA_STBD
Mouse is over