зеркало из https://github.com/mono/mail-archives.git
117 строки
4.3 KiB
HTML
117 строки
4.3 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||
|
<HTML>
|
||
|
<HEAD>
|
||
|
<TITLE> [Gtk-sharp-list] Gtk entry only for digits?
|
||
|
</TITLE>
|
||
|
<LINK REL="Index" HREF="index.html" >
|
||
|
<LINK REL="made" HREF="mailto:26031%40t-link.de">
|
||
|
<META NAME="robots" CONTENT="index,nofollow">
|
||
|
|
||
|
<LINK REL="Previous" HREF="004790.html">
|
||
|
<LINK REL="Next" HREF="004793.html">
|
||
|
</HEAD>
|
||
|
<BODY BGCOLOR="#ffffff">
|
||
|
<H1>[Gtk-sharp-list] Gtk entry only for digits?
|
||
|
</H1>
|
||
|
<B>Michael
|
||
|
</B>
|
||
|
<A HREF="mailto:26031%40t-link.de"
|
||
|
TITLE="[Gtk-sharp-list] Gtk entry only for digits?">26031@t-link.de
|
||
|
</A><BR>
|
||
|
<I>Sun, 29 Aug 2004 19:31:54 +0200</I>
|
||
|
<P><UL>
|
||
|
<LI> Previous message: <A HREF="004790.html">[Gtk-sharp-list] Gtk entry only for digits?
|
||
|
</A></li>
|
||
|
<LI> Next message: <A HREF="004793.html">[Gtk-sharp-list] Window+buttons
|
||
|
</A></li>
|
||
|
<LI> <B>Messages sorted by:</B>
|
||
|
<a href="date.html#4792">[ date ]</a>
|
||
|
<a href="thread.html#4792">[ thread ]</a>
|
||
|
<a href="subject.html#4792">[ subject ]</a>
|
||
|
<a href="author.html#4792">[ author ]</a>
|
||
|
</LI>
|
||
|
</UL>
|
||
|
<HR>
|
||
|
<!--beginarticle-->
|
||
|
<PRE>Jop, helped a lot :-)
|
||
|
|
||
|
I did it that way:
|
||
|
|
||
|
void InsertText(object o, TextInsertedArgs args)
|
||
|
{
|
||
|
if(args.Text.Equals("1") || args.Text.Equals("2")
|
||
|
|| args.Text.Equals("3")
|
||
|
||<i> args.Text.Equals("4") ||
|
||
|
</I> args.Text.Equals("5") ||args.Text.Equals("6")
|
||
|
||args.Text.Equals("7") ||args.Text.Equals("8")
|
||
|
||args.Text.Equals("9") ||args.Text.Equals("0"))
|
||
|
{
|
||
|
Console.WriteLine("Number pressed "+ args.Text);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if(entry1.CursorPosition.Equals(0))
|
||
|
{
|
||
|
entry1.DeleteText(entry1.CursorPosition-2,entry1.CursorPosition-1);
|
||
|
Console.WriteLine("Text0: "+ args.Text);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
entry1.DeleteText(entry1.CursorPosition,entry1.CursorPosition+1);
|
||
|
Console.WriteLine("Text1: "+ args.Text);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@ Draek: With KeyPressEventArgs you do not get any output in the console
|
||
|
if a digit is pressed. Only 'special keys' show an output.
|
||
|
|
||
|
Thanks a lot @ all
|
||
|
|
||
|
Michael
|
||
|
|
||
|
|
||
|
On Sun, 2004-08-29 at 12:51, Philipp Kern wrote:
|
||
|
><i> On So, 2004-08-29 at 09:41, Draek wrote:
|
||
|
</I>><i> > I'm sure that you can do it with KeyPressEventArgs. What I would do
|
||
|
</I>if I
|
||
|
><i> > was you is print the key code that is received to the console when
|
||
|
</I>you
|
||
|
><i> > press numbers you will see what the key code is, just do a switch
|
||
|
</I>><i> > statement on that keycode as a string and your set, only print the
|
||
|
</I>><i> > numbers not letters.
|
||
|
</I>><i>
|
||
|
</I>><i> Although I really do not know how to reach an Entry field without
|
||
|
</I>alpha
|
||
|
><i> characters, this hardware method doesn't seem very natural to me.
|
||
|
</I>><i> You get the hardware keycodes, so for providing proper editing
|
||
|
</I>features
|
||
|
><i> you would also have to check the keypad (and if numlock is really on)
|
||
|
</I>><i> etc.
|
||
|
</I>><i>
|
||
|
</I>><i> Perhaps you might want to play with "insert_text" and int
|
||
|
</I>><i> System.Int32.Parse(string).
|
||
|
</I>><i>
|
||
|
</I>><i> Hope to help you just a little bit,
|
||
|
</I>><i> Philipp Kern
|
||
|
</I>
|
||
|
|
||
|
|
||
|
</PRE>
|
||
|
<!--endarticle-->
|
||
|
<HR>
|
||
|
<P><UL>
|
||
|
<!--threads-->
|
||
|
<LI> Previous message: <A HREF="004790.html">[Gtk-sharp-list] Gtk entry only for digits?
|
||
|
</A></li>
|
||
|
<LI> Next message: <A HREF="004793.html">[Gtk-sharp-list] Window+buttons
|
||
|
</A></li>
|
||
|
<LI> <B>Messages sorted by:</B>
|
||
|
<a href="date.html#4792">[ date ]</a>
|
||
|
<a href="thread.html#4792">[ thread ]</a>
|
||
|
<a href="subject.html#4792">[ subject ]</a>
|
||
|
<a href="author.html#4792">[ author ]</a>
|
||
|
</LI>
|
||
|
</UL>
|
||
|
</body></html>
|