Why is Mouse Pressed Event not working in TextArea of JavaFX? -


this code:

@fxml private textarea txtconfig; public void handlemousepressed(mouseevent mouseevent) {         txtconfig.setonmousepressed(new eventhandler<mouseevent>() {             @override             public void handle(mouseevent event) {                 system.out.println("pressed");             }         });     } 

in fxml:

textarea fx:id="txtconfig"  style="-fx-font-size:10pt; -fx-font-family:consolas"               maxwidth="infinity" maxheight="infinity" vbox.vgrow="always"               onmousepressed="#handlemousepressed"/> 

however, setonmouseclicked working keeping same. only, onmousepressed changed onmouseclicked in fxml.

public void handlemouseclicked(mouseevent mouseevent) {         txtconfig.setonmouseclicked(new eventhandler<mouseevent>() {             @override             public void handle(mouseevent event) {                  system.out.println("clicked");             }         });      } 

as suggested in this answer install Èventfilter if need mousepressed event (which seems consumed control itself):

txtconfig.addeventfilter(     mouseevent.mouse_pressed,     new eventhandler<mouseevent>() {         @override         public void handle(mouseevent event) {             system.out.println("pressed");         }     } ); 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -