2

So still kind of figuring out JavaFX, I was able to disable entering text in the textbox but I am not sure how to prevent the context menu from coming up when right clicked. Is anybody aware of how to prevent the default context menu from popping up when right clicked? `

//CombatFeedback is scrollable textbox to update user on what's     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);`
2
  • possible duplicate of stackoverflow.com/questions/13562712/… Commented Mar 30, 2017 at 18:04
  • 1
    My impression was that that question dealt with a much earlier version of the JavaFX toolkit because of the double screen problem. I assumed the more recent JavaFX would be able to offer a less convoluted and more straightforward solution. Sorry if that isn't the case though.
    – Strom
    Commented Mar 30, 2017 at 19:34

1 Answer 1

13

You can consume the event that signifies a request has been made for a context menu:

CombatFeedback.addEventFilter(ContextMenuEvent.CONTEXT_MENU_REQUESTED, Event::consume);
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.