title: JavaFX how to clear TextField when mouse is clicked on it
body: <p>I have a problem with chosing correct action on TextField. On Java  class:</p>
  <pre class="lang-java prettyprint-override"><code>@FXML
  private TextField projectNameInput;
      
  @FXML
  private void clearProjectName(MouseEvent event) {
  
      // some if - else statements
      projectNameInput.clear();
  }
  </code></pre>
  <p>On FXML it looks like this:</p>
  <pre><code>&lt;TextField fx:id=&quot;projectNameInput&quot; onMouseClicked=&quot;#clearProjectName&quot; GridPane.columnIndex=&quot;1&quot;&gt;
  </code></pre>
  <p>I tried most options, in Java I tried (as arg) Event, MouseEvent, ActionEvent, combined with FXML <code>onAction</code>, etc but no luck. What kind of action should I choose that when I click the mouse button on TextField it will be automatically cleared?</p>