title: Determine if an event was consumed in JavaFX
body: <p>I'm trying to do some off-piste stuff with event handling in JavaFX. I need to be able to determine if an event was consumed after I manually fire it.</p>
  
  <p>In the following example a synthetic mouse event is correctly received, however calling consume() does not update the event.</p>
  
  <p>I've debugged this and found JavaFX actually creates a new event instance so the original is unchanged</p>
  
  <pre><code>public class EventManipulation extends Application {
  
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          Button button = new Button();
          button.setOnMouseDragged(event -&gt; {
              System.out.println("dragged");
              event.consume();
          });
          primaryStage.setScene(new Scene(new HBox(button), 400, 300));
          primaryStage.show();
  
          MouseEvent event = new MouseEvent(MouseEvent.MOUSE_DRAGGED, 0, 0, 0, 0, MouseButton.PRIMARY, 1, false, false,
                  false, false, false, false, false, false, false, false, null);
          Event.fireEvent(button, event);
          System.out.println(event.isConsumed());  // &lt;== prints false
      }
  }
  </code></pre>
  
  <p>I've discovered EventDispatchChain, however I cannot figure out how to get this to work. The button can generate a event dispatch chain but requires one to start off with... The following fails because I don't know how to create an initial tail.</p>
  
  <pre><code>Event result = button.buildEventDispatchChain(null).dispatchEvent(event);
  System.out.println(result.isConsumed());
  </code></pre>