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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -