Is it possible to set OnCloseRequest event handler for a Stage from within it's Scene's controller?
I'm not sure I'm being clear enough, so here is the scenario:
User opens an item for editing from the list of items. Item editor is in a new window. The user makes some changes, does not save them and tries to close the editor. In that instance I want the program to ask her whether she wants to save the changes, close without saving or cancel closing.
Of course, I want to setOnCloseRequest(EventListener<WindowEvent>) for the editor. :) Any thoughts or suggestions? It doesn't have to be my way, I just care about the functionality.
Actually, this was stupid, because it doesn't work until you assign current Scene to a Stage. So, in early phases (i.e. initialization) it causes the NullPointerException to be thrown. So, the only way is from the outside?
Just talking to myself here.... perfectly normal... B-)