Re: Control Closing of Gtk::Dialog



Robert Pearce wrote:
On Sun, 15 Feb 2009, Murray Cumming <murrayc murrayc com> wrote :
On Sun, 2009-02-15 at 15:51 +0100, Jon Black wrote:
I have a simple Gtk::Dialog with 3 text entry fields, a cancel button,
and an ok button. I'd like the dialog to close whenever the user
presses cancel, and when the user presses ok only if all the text
entry fields contain text.
<snip>

I think you can override on_response() to prevent run() from returning.
I forget the details.

As an alternative (slight change to behaviour) you could hook up to the "on change" signals of the text fields, and set the OK button's sensitivity according to their new contents. Thus the OK button would be greyed out until it's valid to press. It's a bit more work but some might think it's a nicer user interface.
I did consider this method myself, but imagine the user enters incorrect information. You'd want to inform them. I suppose it could be done when the text is changed in a text box, but imagine a pop-up message when you leave a text-box? I'd find that annoying, so then the Ok button seems the better place.

Perhaps I don't need a modal dialog in this case, but it still leaves me with an unsettled feeling that the dialog class doesn't really give me simple control over when it's shown.

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