TreeView: reacting on mouse up's


#1

Right now, there’s only TreeViewItem::itemClicked(). Would it be possible to enhance this so it would contain: itemMouseDown(), itemMouseUp() ?
I tried all sorts of stuff using a MouseListener but it crashes, my code was like this:

[code]
class MyTreeViewItem:public TreeViewItem, public MouseListener
{
void itemClicked(const MouseEvent &e)
{
e.originalComponent->addMouseListener(this, false);

}

void mouseUp(const MouseEvent &e)
{
    e.originalComponent->removeMouseListener(this);
    ...
}

}[/code]

… and somehow, when I drag’n’drop the TreeViewItem onto another DragAndDropTarget, then I get a crash (access violation) in Component::MouseListenerList::sendMouseEvent() after releasing the mouse button, in this line:

Maybe there’s another, simple solution? Thanks for help.


#2

I’m going to add a comment in the TreeViewItem code saying “No, I will not be adding any more f**king callbacks to this class!” as I’m getting tired of answering this same kind of request!

If I added itemMouseUp, then people would ask for imageMouseWheel… then itemKeyDown, etc. etc and eventually it’d end up as big as the component class. If you need fancy behaviours, you should use TreeViewItem::createItemComponent().


#3

I know there’s createItemComponent(), I just didn’t want to create 1 Component per Item, because this could generate thousands of Components. I don’t think it would make the TreeView as responsive. I just wanted a mouseUp notification, because when the Item is clicked, it should start playing audio, and when mouse is released it should just stop audio.


#4

It’ll only create components for the on-screen items in the tree (unless I’ve mis-remembered how it works…)