简体   繁体   中英

tree nodeSelectListener

nodeSelectListener will only trigger if the node is previously not selected. If a node is already selected, and we press the same node again, the listener will not be called. how to overwrite this so that every single click even on the same node will fire nodeSelectListener?

You can't do it via that particular listener, because (by design) the select listener only fires when the node was not previously selected. See this bug report for a discussion of it. You want an onclick handler instead.

java isn't really my forte, but perhaps instead of replacing the listener altogether, you could make the onclick handler just deselect and then reselect the node?

How about using MouseListener beside nodeSelectListener ?

I really DON'T know what I'm talking about... but is this possible?

On select, collect the size and position of the node, along with the node itself. Then on click, see if you're on the same node by seeing if the current position is within the rectangle. Be sure to clear the saved selection info when necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM