Alright, here's one that uses a DialogStateListener (exactly the same
concept as SheetStateListener, but different name, basically).  This
allows the close if user clicks 'Cancel' or hits the Escape key, but if
"OK" is clicked or Enter pressed, then it tries to start the operation
and only if successful, allows the dialog to close.  Hopefully this will
give you enough to get going with yours...

public class QueryRecordingDialog
        extends DialogStateListener.Adapter
...
            dialog.getDialogStateListeners().add(this);
...
            dialog.open(mainWindow, this);
...
        /**
         * So, the user wants to close the dialog (either with "Start"
or
         * "Cancel").  If "Start", then ensure we have a non-empty file
         * name and that we can start recording to it before allowing
         * the close.
         */
        @Override
        public Vote previewDialogClose(Dialog dialog, boolean result) {
            if (result == false)
                return Vote.APPROVE;
            // Validate the fields before going on
            String fileName = fileNameInput.getText().trim();
            if (fileName.isEmpty())
                return Vote.DENY;
            QueryRecording qr = new QueryRecording(kindChoice,
legacyModeCheck.isSelected());
            try {
                qr.startRecording(fileName, appendCheck.isSelected());
                appObj.setRecordButtonState(true);
            }
            catch (Exception e) {
                MessageDialog.showException(dialog, e);
                return Vote.DENY;
            }
            return Vote.APPROVE;
        }

~Roger

-----Original Message-----
From: mattux [mailto:[email protected]] 
Sent: Monday, May 21, 2012 1:46 AM
To: [email protected]
Subject: RE: Prompt: override option click event

Hi Roger,

I think your idea of a SheetStateListener is what I was looking for!!

If you have some samples in hand, I wouldn't mind you sharing them.
Otherwise, don't worry, I will try and find out.

Many thanks for your help, much appreciated! Just started on Pivot so it
has
been a nice help!

Regards,
Matt

--
View this message in context:
http://apache-pivot-users.399431.n3.nabble.com/Prompt-override-option-cl
ick-event-tp3999325p4004527.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Reply via email to