ListView Double-Click Actions

In the ListView, if you want to get the current item on double click, you cannot use mouseDownAction, since it won’t have the current item if you click on another item. And mouseUpAction has no clickCount.
So you would have to do something like this:

(
v=FlowView.new;
p=0;
l = ListView(v,Rect(0,0,120,300));

12.do{|i|
l.items = l.items.add("item"+i);
};

l.mouseUpAction_{|v| (p>1).if{v.items[v.value].postln}};
l.mouseDownAction={|v,x,y,m,b,clickCount| p=clickCount;clickCount.postln };

)

This is actually the ONLY way to implement a double click action in the ListView. How tedious.

Here is a more elegant solution:

+View{

    doubleClickAction_{|argAction|
        var clickCount;
        this.mouseUpAction={|v,x,y,m,b| (clickCount==2).if{argAction.value(v,x,y,m,b,clickCount)}};
        this.mouseDownAction={|v,x,y,m,b,cc| clickCount=cc;};
    }

}


(
v=FlowView.new;

l = ListView(v,Rect(0,0,120,300));

12.do{|i|
l.items = l.items.add("item"+i);
};

l.doubleClickAction = {|v,x,y,m,b,clickCount| v.items[v.value].postln};

)