package net.christophermerrill.FancyFxTree;

import javafx.event.*;
import javafx.scene.control.*;
import javafx.scene.input.*;

/**
 * Intercepts double-click events BEFORE the tree can use it for expand/collapsing of nodes. Provided
 * with a MouseListener, this allows the double-click event to be used for editing the node, rather than
 * expand/collapse.
 *
 * @author Christopher L Merrill (see LICENSE.txt for license details)
 */
class DoubleClickInterceptor implements EventDispatcher
    {
    DoubleClickInterceptor(TreeCell cell, EventHandler<MouseEvent> double_click_listener)
        {
        _original_dispatcher = cell.getEventDispatcher();
        cell.setEventDispatcher(this);
        _double_click_listener = double_click_listener;
        }

    @Override
    public Event dispatchEvent(Event event, EventDispatchChain tail)
        {
        if (event instanceof MouseEvent)
            {
            MouseEvent mouse_event = (MouseEvent) event;
            if (mouse_event.getEventType().equals(MouseEvent.MOUSE_PRESSED)
                && mouse_event.getButton() == MouseButton.PRIMARY
                && mouse_event.getClickCount() >= 2
                && !event.isConsumed())
                {
                _double_click_listener.handle(mouse_event);
                event.consume();
                }
            }
        return _original_dispatcher.dispatchEvent(event, tail);
        }

    private final EventDispatcher _original_dispatcher;
    private final EventHandler<MouseEvent> _double_click_listener;
    }



@@ -463,35 +463,8 @@
 ptor
- implements EventDispatcher
 %0A   
@@ -579,372 +579,121 @@
    _
-original_dispatcher = cell.getEventDispatcher();%0A        cell.setEventDispatcher(this);%0A        _double_click_listener = double_click_listener;%0A        %7D%0A%0A    @Override%0A    public Event dispatchEvent(Event event, EventDispatchChain tail)%0A        %7B%0A        if (event instanceof MouseEvent)%0A            %7B%0A            MouseEvent mouse_event = (MouseEvent) event;%0A
+double_click_listener = double_click_listener;%0A        cell.addEventHandler(MouseEvent.ANY, event -%3E%0A%09    
     
+%7B%0A%09
     
@@ -700,22 +700,16 @@
     if (
-mouse_
 event.ge
@@ -713,78 +713,29 @@
 .get
-EventType().equals(MouseEvent.MOUSE_PRESSED)%0A                && mouse_
+ClickCount() == 2 && 
 even
@@ -747,20 +747,24 @@
 Button()
- == 
+.equals(
 MouseBut
@@ -774,25 +774,29 @@
 .PRIMARY
-%0A
+))%0A%09%09
         
         
@@ -787,24 +787,28 @@
         
+%7B%0A%09%09
         
 && mouse
@@ -803,118 +803,77 @@
     
-&& mouse_event.getClickCount() %3E= 2%0A                && !event.isConsumed())%0A                %7B%0A        
+if (event.getEventType().equals(MouseEvent.MOUSE_CLICKED))%0A%09%09
         
 _dou
@@ -860,32 +860,33 @@
 KED))%0A%09%09        
+%09
 _double_click_li
@@ -903,22 +903,16 @@
 dle(
-mouse_
 event);%0A
     
@@ -907,20 +907,17 @@
 event);%0A
-    
+%09
         
@@ -937,24 +937,18 @@
 sume();%0A
-        
+%09%09
         
@@ -949,25 +949,25 @@
       %7D%0A
- 
+%09
         
    %7D%0A   
@@ -962,143 +962,22 @@
     
-   %7D%0A        return _original_dispatcher.dispatchEvent(event, tail);%0A        %7D%0A%0A    private final EventDispatcher _original_dispatcher;
+%7D);%0A        %7D%0A
 %0A   

Switch to using a mouse event handler instead of EventDispatcher