You could just encapsulate the endEdit(...)
method call in a @FXML
annotated method that handles the action event. Something like this:
public class FXMLController implements Initializable {
@FXML
protected void handleTextFieldAction(ActionEvent e) {
endEdit(false);
}
private void endEdit(boolean flag) {
System.out.println("Flag value: " + flag);
// Your implementation here
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
Then in your FXML
file bind the text field's onAction property to this handleTextFieldAction(...)
method like this:
<TextField onAction="#handleTextFieldAction" />
If the boolean flag actually depends on some conditions that have to be evaluated then you can process them within handleTextFieldAction(...)
method and call endEdit(...)
with the appropriate value.