I’m building a GUI with the SimpleSwingApplication trait in scala swing.
What I want to do is to provide a mechanism on close, that asks the user (Yes,No,Cancel) if he didn’t save the document yet. If the user hits Cancel the Application shouldn’t close. But everything I tried so far with MainFrame.close and closeOperation didn’t work.
So how is this done in Scala Swing?
I’m on Scala 2.9.
Thanks in advance.
Slightly different variation from what Howard suggested
By using
DO_NOTHING_ON_CLOSEyou are given a chance to define what should be done when aWindowEvent.WINDOW_CLOSINGevent is received by the scala frame. When a scala frame receives aWINDOW_CLOSINGevent it reacts by callingcloseOperation. Hence, to display a dialog when the user attempts to close the frame it is enough to overridecloseOperationand implement the desired behavior.