3 Replies Latest reply: Nov 22, 2012 3:49 AM by daniel RSS

    How to add double mouse click enent handler in javafx builder

    975590
      I want to handle the double mouse click event, I want to know how can I bundle a function in Controller to handle the event using javafx builder1.0 ?
      Does anyone knows?

      Thanks very much for your help!!
        • 1. Re: How to add double mouse click enent handler in javafx builder
          dscarminiabielefeld
          Hi,
          i don't know if there is an event for a double mouseclick, i dont think so. But i think there are other ways to get the same effect as a double click on something. But you can't implement any code in the builder, you only can define a function on the right side of your builder, in the part where it says 'Code : '.
          But I've never used it anyway. Why don't you just implement your eventhandler by yourself in a java file?

          Greetings.
          • 2. Re: How to add double mouse click enent handler in javafx builder
            975590
            Thank you for your reply.
            I have implemented it by myself, not using javafx builder, just like your advice.
            For my other event handlers are all using javafx, so I think it will be look elegant, or say it neat using this in my all event handlers. :)

            Thanks for your reply again. :)
            • 3. Re: How to add double mouse click enent handler in javafx builder
              daniel
              Hi,

              Are you asking how to connect a Controller's method that handles a mouse double click event to a node in the scenegraph using SceneBuilder 1.0?

              If so here is how:

              Open your FXML file in SceneBuilder.
              Select the node you want to register the handler on.
              Open the code section (Right hand side)
              Add a method name for On Mouse Clicked - preceded by the # sign - e.g.

              #handleMouseClicked

              then invoke View > Show Sample Controller Skeleton

              copy the declaration for your method (handleMouseClicked if that's how you named it) - it should be something like:
                  // Handler for AnchorPane[AnchorPane[id=null]] onMouseClicked
                  public void handleMouseClicked(MouseEvent event) {
                      // handle the event here
                  }
              and paste it in your controller class.

              In the method body - examine the MouseEvent to see if it is a simple click or a double click.

              Hope this helps,

              -- daniel