mail-archives/gtk-sharp-list/2004-August/004792.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(&quot;1&quot;) || args.Text.Equals(&quot;2&quot;)
|| args.Text.Equals(&quot;3&quot;)
||<i> args.Text.Equals(&quot;4&quot;) ||
</I> args.Text.Equals(&quot;5&quot;) ||args.Text.Equals(&quot;6&quot;)
||args.Text.Equals(&quot;7&quot;) ||args.Text.Equals(&quot;8&quot;)
||args.Text.Equals(&quot;9&quot;) ||args.Text.Equals(&quot;0&quot;))
{
Console.WriteLine(&quot;Number pressed &quot;+ args.Text);
}
else
{
if(entry1.CursorPosition.Equals(0))
{
entry1.DeleteText(entry1.CursorPosition-2,entry1.CursorPosition-1);
Console.WriteLine(&quot;Text0: &quot;+ args.Text);
}
else
{
entry1.DeleteText(entry1.CursorPosition,entry1.CursorPosition+1);
Console.WriteLine(&quot;Text1: &quot;+ 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:
&gt;<i> On So, 2004-08-29 at 09:41, Draek wrote:
</I>&gt;<i> &gt; I'm sure that you can do it with KeyPressEventArgs. What I would do
</I>if I
&gt;<i> &gt; was you is print the key code that is received to the console when
</I>you
&gt;<i> &gt; press numbers you will see what the key code is, just do a switch
</I>&gt;<i> &gt; statement on that keycode as a string and your set, only print the
</I>&gt;<i> &gt; numbers not letters.
</I>&gt;<i>
</I>&gt;<i> Although I really do not know how to reach an Entry field without
</I>alpha
&gt;<i> characters, this hardware method doesn't seem very natural to me.
</I>&gt;<i> You get the hardware keycodes, so for providing proper editing
</I>features
&gt;<i> you would also have to check the keypad (and if numlock is really on)
</I>&gt;<i> etc.
</I>&gt;<i>
</I>&gt;<i> Perhaps you might want to play with &quot;insert_text&quot; and int
</I>&gt;<i> System.Int32.Parse(string).
</I>&gt;<i>
</I>&gt;<i> Hope to help you just a little bit,
</I>&gt;<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>