AlmasB / FXGL

Java / JavaFX / Kotlin Game Library (Engine)
http://almasb.github.io/FXGL/
MIT License
4.42k stars 554 forks source link

Add EntityBuilder DSL methods to add extra mouse event handlers, similar to existing onClick #1196

Open AlmasB opened 2 years ago

AlmasB commented 2 years ago

Discussed in https://github.com/AlmasB/FXGL/discussions/1099

Originally posted by **francescvc** September 2, 2021 On entityBuilder() I can setup an onClick((ent)-> { ... }) but on the click code I can't make difference upon the button clicked, that is the left one or right one. ¿How can I attach different events to both mousebuttons, or how can I distinguish wich one was clicked?
chengenzhao commented 2 years ago

how about a general method of mouse event like

entityBuilder.onMouseEvent((entity, event) -> {
  if(event instanceof MouseDragEvent dragEvent){
    //drag event handler
  }else{
    //other normal mouse event handler
  }
});

?