3 Replies Latest reply on Dec 10, 2014 6:14 AM by BurrowsTD

    ScriptUI: Are there ways to mimic a treeview node doubleclick?

    Andreas Jansson Level 2



      Is there a way to mimic a double click on a node in a ScriptUI Treeview?

      I find no suitable event on the Treeview or on the Listitem (node) objects.

      Are there workarounds for this?


      Just thinking out loud:


      Could a Listitem (node) be located, from the coordinates of the mouse move event?


      Is it possible to put other objects than ListItems inside the treeview – on top of the active list item in the TreeView.onChange event – just to get a better set of events?


      Other ways...?


      Best regards,


        • 1. Re: ScriptUI: Are there ways to mimic a treeview node doubleclick?
          Peter Kahrel Adobe Community Professional & MVP



          Nodes can be used for double-click without any problem. That is to say, you check if the tree has been double-clicked, then you check what in the trees was clicked. Something like this:



          myTree.onDoubleClick = doSomething;
          function doSomething{
             if (/*some valid selection*/){
                . . .
                . . .


          Locating a list item from the coordinates of a move mouse event would be very difficult I guess.




          Message was edited by: PK

          • 2. Re: ScriptUI: Are there ways to mimic a treeview node doubleclick?
            Andreas Jansson Level 2

            Thanks Peter, you are perfectly right!


            I must have looked at the node (listitem) only, when I checked for an onDoubleClick event on objects by reflection, since it's obviously there, when I check the TreeView today:



            Result: [object TreeView]


            Result: onExpand,onDoubleClick,removeAll,....


            Also, I was probably tricked into believing that the treeview lacked this event,

            from page 81 in the JavaScript Tools Guide for CS6 (it seemed to me that listbox was the only one of the three similar controls that had the double click event):


            * ListBox, DropDownList, and TreeView controls generate events whenever the selection in the list

            changes. To handle the event, define a callback function for onChange. The TreeView control also

            generates events when the user expands or collapses a node, handled by the onExpand and

            onCollapse callback functions.


            * The ListBox also generates an event when the user double-clicks an item. To handle it, define a callback function for the onDoubleClick event.



            Best regards,


            • 3. Re: ScriptUI: Are there ways to mimic a treeview node doubleclick?

              I have written a dynamic treeview that creates tree items based on a set of scripts in a given folder. It works fine if I use single click access on a selected node, but I wanted to create a double click function. However, I have noticed that the double click function I created in Extendscript works fine when I run it in that environment, but when it is run in AFX cs6, the doubleclick does not work.


              myOnDoubleClick = function(event)


                                          if(event.detail ==  2)


                                              var script = (event.target.selection.text);

                                              if (event.target.selection.text  !==  "my AFX Scripts") {runSelectedScript(script); }

                                              else if(event.target.selection.text  ===  "my AFX Scripts") {cantRunThis();  }



                                     myAFXScriptPanel.grp.groupOne.myMultiTreeView.addEventListener('click', myOnDoubleClick);

              //END OF SCRIPT


              runSelectedScript(script) is a function that takes the selected item text and concatenates it with a path and extension and then executes the script. As stated, works fine in Extendscript environment, but will not function in After Effects. The other function (cantRunThis) just creates an alert if the top node of the tree is selected.