зеркало из https://github.com/mono/mail-archives.git
117 строки
4.5 KiB
HTML
117 строки
4.5 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||
|
<HTML>
|
||
|
<HEAD>
|
||
|
<TITLE> [Gtk-sharp-list] How to validate input on Gtk.Dialog?
|
||
|
</TITLE>
|
||
|
<LINK REL="Index" HREF="index.html" >
|
||
|
<LINK REL="made" HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20How%20to%20validate%20input%20on%20Gtk.Dialog%3F&In-Reply-To=">
|
||
|
<META NAME="robots" CONTENT="index,nofollow">
|
||
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
||
|
<LINK REL="Previous" HREF="006369.html">
|
||
|
<LINK REL="Next" HREF="006375.html">
|
||
|
</HEAD>
|
||
|
<BODY BGCOLOR="#ffffff">
|
||
|
<H1>[Gtk-sharp-list] How to validate input on Gtk.Dialog?</H1>
|
||
|
<B>Paul Wallimann</B>
|
||
|
<A HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20How%20to%20validate%20input%20on%20Gtk.Dialog%3F&In-Reply-To="
|
||
|
TITLE="[Gtk-sharp-list] How to validate input on Gtk.Dialog?">pwallimann at hotmail.com
|
||
|
</A><BR>
|
||
|
<I>Mon Sep 5 13:12:33 EDT 2005</I>
|
||
|
<P><UL>
|
||
|
<LI>Previous message: <A HREF="006369.html">[Gtk-sharp-list] [NEWBIE] Menu image, submenu items and more
|
||
|
</A></li>
|
||
|
<LI>Next message: <A HREF="006375.html">[Gtk-sharp-list] How to validate input on Gtk.Dialog?
|
||
|
</A></li>
|
||
|
<LI> <B>Messages sorted by:</B>
|
||
|
<a href="date.html#6373">[ date ]</a>
|
||
|
<a href="thread.html#6373">[ thread ]</a>
|
||
|
<a href="subject.html#6373">[ subject ]</a>
|
||
|
<a href="author.html#6373">[ author ]</a>
|
||
|
</LI>
|
||
|
</UL>
|
||
|
<HR>
|
||
|
<!--beginarticle-->
|
||
|
<PRE>I am still rather new to GTK# and currently struggling with the following:
|
||
|
I want to implement a (modal) Login Dialog that only returns to the calling
|
||
|
method when the user either hits Cancel or enters the correct password and
|
||
|
hits OK. When the user enters the wrong password and hits OK the dialog
|
||
|
should remain open.
|
||
|
|
||
|
I thought I could implement this by simply subclassing from Gtk.Dialog.
|
||
|
Unfortunately, the dialog gets closed immediately after either of the 2
|
||
|
buttons is hit and I have not found a way to execute the validation and
|
||
|
keep the dialog open when the password is wrong. Following is my code
|
||
|
(using gtk-sharp, Version=2.4.0.0):
|
||
|
|
||
|
using System;
|
||
|
using Gtk;
|
||
|
|
||
|
namespace Testing
|
||
|
{
|
||
|
public class LoginDialog : Dialog
|
||
|
{
|
||
|
public static void Main (string[] args)
|
||
|
{
|
||
|
Application.Init();
|
||
|
|
||
|
LoginDialog dlg = new LoginDialog();
|
||
|
dlg.Modal = true;
|
||
|
int response = dlg.Run();
|
||
|
Console.WriteLine("Main: Response was {0}", (ResponseType)response);
|
||
|
dlg.Destroy();
|
||
|
}
|
||
|
|
||
|
public LoginDialog()
|
||
|
: base()
|
||
|
{
|
||
|
this.AddButton(Stock.Cancel, ResponseType.Cancel);
|
||
|
this.AddButton(Stock.Ok, ResponseType.Ok);
|
||
|
this.Response += new ResponseHandler(On_dialog_response);
|
||
|
}
|
||
|
private void On_dialog_response (object obj, ResponseArgs args)
|
||
|
{
|
||
|
Console.WriteLine ("On_dialog_response: args.ResponseId = {0}",
|
||
|
args.ResponseId);
|
||
|
if (args.ResponseId == ResponseType.Ok)
|
||
|
args.RetVal = false; // keep dialog open
|
||
|
}
|
||
|
protected override bool OnDeleteEvent(Gdk.Event e)
|
||
|
{
|
||
|
// This method is not called. Why?
|
||
|
Console.WriteLine("OnDeleteEvent: called");
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
I would appreciate if someone could tell me how to do it correctly or point
|
||
|
me to an appropriate resource on the internet. Thanks in advance.
|
||
|
|
||
|
Regards,
|
||
|
Paul Wallimann
|
||
|
|
||
|
</PRE>
|
||
|
|
||
|
|
||
|
<!--endarticle-->
|
||
|
<HR>
|
||
|
<P><UL>
|
||
|
<!--threads-->
|
||
|
<LI>Previous message: <A HREF="006369.html">[Gtk-sharp-list] [NEWBIE] Menu image, submenu items and more
|
||
|
</A></li>
|
||
|
<LI>Next message: <A HREF="006375.html">[Gtk-sharp-list] How to validate input on Gtk.Dialog?
|
||
|
</A></li>
|
||
|
<LI> <B>Messages sorted by:</B>
|
||
|
<a href="date.html#6373">[ date ]</a>
|
||
|
<a href="thread.html#6373">[ thread ]</a>
|
||
|
<a href="subject.html#6373">[ subject ]</a>
|
||
|
<a href="author.html#6373">[ author ]</a>
|
||
|
</LI>
|
||
|
</UL>
|
||
|
|
||
|
<hr>
|
||
|
<a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">More information about the Gtk-sharp-list
|
||
|
mailing list</a><br>
|
||
|
</body></html>
|