1

私人无效 gotoRightClick() {

     textArea.setOnMouseClicked(new EventHandler<MouseEvent>(){

        @Override
        public void handle(MouseEvent event) {
            if(event.isSecondaryButtonDown())
            {
                System.out.println("right click pressed in text area");
            }
        }
    });

  tableView.setOnMouseClicked(new EventHandler<MouseEvent>(){

        @Override
        public void handle(MouseEvent e) {
            if(e.isSecondaryButtonDown())
            {
                System.out.println("right click pressed in table view");
            }
        }
    });
}

没有检测到任何事件可以帮助我吗?谢谢提前

4

1 回答 1

0

试试这个:

this.setOnMouseClicked(new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent event) {
                if (event.getButton().equals(MouseButton.SECONDARY)) {
                    //do something
                }
            }
        });
于 2012-10-20T03:54:46.303 回答