Re: Verifying input data before gtk_dialog_run returns



On Wed, 21 Mar 2007, Jaap Haitsma wrote:

Is there a recommended way to check if the data in a dialog is valid when the user presses the OK button? If the data is not OK I want to present a modal dialog saying there is an error. If the user closes that dialog the user can correct the error and press OK again.

I have some dialogs of this sort in my app. For these I don't use gtk_dialog_run(). I construct a dialog widget and let it just "sit there" until it is explicitly destroyed. I have a callback attached to the Enter key and/or an OK button. This callback checks the validity of the dialog data and

* if the user input is OK, destroys the dialog and calls the
  next task; but

* if the input is not OK, leaves the dialog open, and
  superimposes a modal dialog (with a single OK or Dismiss
  button) saying that the input was invalid.  Closing this
  latter dialog leaves the original dialog as the focused
  widget.

If you follow this model, it's a nice courtesy to offer the
user a way out: a Cancel button in the original dialog,
which allows them to say, "The heck with this 'invalid input',
I'm out of here."

Allin Cottrell




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]