The following code disables the default context menu of all the existing TextField
added to Scene
.
for (Node node : scene.getRoot().lookupAll("*")) {
if (node instanceof TextField) {
((TextField)node).setContextMenu(new ContextMenu());
}
}
But if you add another TextField
to Scene
later, its default context menu is not disabled.
If you run the code above each time you add TextField
s, there would be no problem, but it is rather troublesome.
So are there any way to disable the default context menu of all the TextField
(including ones added in the scene graph later)?
TextField
implementation which does this upon creation, or use a factory method that does this for you. What is the usecase?