[MonoDevelop] Is it possible to do the VS equivalent to E.CANCEL in a Gtk.Dialog ?

Chris Howie cdhowie at gmail.com
Tue Oct 7 21:12:15 EDT 2008


On Tue, Oct 7, 2008 at 8:05 PM, Michael Hutchinson
<m.j.hutchinson at gmail.com> wrote:
> On Tue, Oct 7, 2008 at 5:44 AM, Brett Senior <brett_senior at yahoo.com.au> wrote:
>> I am converting an application from MS/VS/VC# to MD/C# and have the need to
>> prompt the user for some information in a 'window' that is called from the
>> main application.  For this I am using a Dialog and if the response is not
>> valid, I want to stop the OK button from exiting with Ok and thus wish to do
>> the VS equivalent of e.cancel = true which stops the event from executing
>> completely, thus not returning, and thus not returning Ok.  I know that I
>> could return a different response but that seems (to me anyway) the wrong
>> way to approach the problem.  I looked at the System.EventArgs but there
>> were not any fields so I could not see an equivalent.  So, is the above
>> possible in a Gtk.Dialog, or is this a case when a Gtk.Window would be
>> better (but then I cannot centre the window on the main window as I've been
>> there and tried that and this is one of the reasons I am using a Dialog) ?
>> It is probably something simple but for the life of me I can't find it !
>> Any help would be much appreciated.
>
> int responseCode;
> do {
>    responseCode = dialog.Run ();
> } while (responseCode != cancelValue);

Another option is to use Changed events on the dialog's widgets and
pre-validate the input, making the ok button insensitive when there is
invalid input.  This is what a lot of GNOME apps do and provides the
additional benefit of an immediate visual cue.

-- 
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers


More information about the Monodevelop-list mailing list