1
表視圖
私人無效gotoRightClick(){檢測二次鼠標按鈕,在文本區域和使用JavaFX
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");
}
}
});
}
事件沒有被檢測到任何一個能幫助我嗎? 感謝推進
喜阿姆魯在上面的代碼中,我想對文本區域包括文本區域和表格視圖,它正在對錶執行右鍵單擊操作查看它是不工作 – duke
試試這個: table_view.setOnMouseClicked(新的EventHandler(){ @覆蓋 公共無效手柄(的MouseEvent事件){ 如果(event.getButton()等於(MouseButton.SECONDARY)){ 系統。 out.println(「右鍵單擊表格。它在我的情況下,執行 「);} 如果(event.isSecondaryButtonDown()){ 的System.out.println(」 這是從來沒有執行「);} } }); –
amru