[Glade-users] IP input checking



Thank you, hariyanto, it was a great help :)

But I've run into a problem.
The numeric keyboard is ok, but on hungarian keyboards, keycode 49 means zero, and on 19 (the english zero) 
is a special ckarackter.

I'd like to make it work on booth hungarian and english keyboards.
How can I know, what keycode 19 and 49 really represents?

Regards:
Denes

Hariyanto <xhonghar at gmail.com> wrote: I newbie on glade and try this code maybe can help you.
hariyanto

#include "stdlib.h"

gboolean
on_entry1_key_press_event              (GtkWidget       *widget,
                                        GdkEventKey     *event,
                                        gpointer         user_data)
{
gchar *str;
gdouble num;

  if (event->hardware_keycode == 60)
   {  
    str = gtk_entry_get_text(GTK_ENTRY(lookup_widget(frm_main,"entry1")));
    num = atof(str);

    if (num >= 0 && num <=255)
     {
      gtk_widget_grab_focus(GTK_ENTRY(lookup_widget(frm_main,"entry2")));
      return TRUE;    
     }
    else
     {    
      gtk_widget_grab_focus(GTK_ENTRY(lookup_widget(frm_main,"entry1")));    
      return TRUE;          
     }
   }  
  else if (event->hardware_keycode < 10 || event->hardware_keycode > 19)
   {
    g_print("Input not Numeric");
    return TRUE;
   }  
   
  return FALSE;
}

On Mon, 5 Jun 2006 08:27:51 -0700 (PDT)
Denes Matetelki  wrote:


Hi!

I've made 4 text entrys to accept IP addresses. 

How can I check that the input is numeric and in the range 0-255?
It would be nice too if I can move to the next field by pressing the '.' key.

How should it be done?

Best Regards:
Denes


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
Glade-users maillist  -  Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users


                
---------------------------------
How low will we go? Check out Yahoo! Messenger?s low  PC-to-Phone call rates.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20060710/38e63f24/attachment.html 




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