How to disable context menu in JavaFX?

So, while still figuring out JavaFX, I managed to turn off text input in the text box, but I'm not sure how to prevent the context menu from appearing when I right-click. Does anyone know how to prevent the default context menu from appearing when right-clicking? `

//CombatFeedback is scrollable textbox to update user on what happening. TextArea CombatFeedback= new TextArea("Text."); CombatFeedback.setPrefColumnCount(20); CombatFeedback.setPrefRowCount(5); CombatFeedback.setWrapText(true); CombatFeedback.setStyle("-fx-font: 20 arial"); CombatFeedback.setEditable(false); ScrollPane scrollerCombat = new ScrollPane(CombatFeedback);` 
+1
java user-interface javafx
source share
1 answer

You can use an event meaning that the request was requested for the context menu:

 CombatFeedback.addEventFilter(ContextMenuEvent.CONTEXT_MENU_REQUESTED, Event::consume); 
+4
source share

All Articles