GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Dec 20, 2014 7:19 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [SOLVED]GtkEntry & numeric keypad !
PostPosted: Sat Nov 26, 2011 11:06 am 
Offline
Familiar Face

Joined: Fri Mar 25, 2011 7:55 am
Posts: 35
Location: romania
Hi,

With this function i catch a "key-press-event" from a GtkEntry only for digits.
Is working fine, but when i press digits from numeric keypad is not working.
How can i solve this ?

Code:
gint check_entry_ulong( GtkWidget   *widget,
                        GdkEventKey *event,
                        gpointer    *gdata  ) {
   if ( isdigit( event->keyval )) return( FALSE );
   return( TRUE );
} // ***** Function check_entry_ulong ***** //


new code !
Code:
gint check_entry_ulong( GtkWidget   *widget,
                        GdkEventKey *event,
                        gpointer    *gdata  ) {
  if (( event->keyval == 0xFFFFFF ) || (( event->keyval >= 65456 ) && ( event->keyval <= 65465 ))) {
      event->keyval = event->hardware_keycode - 48;
      return( FALSE );
   }
   if ( isdigit( event->keyval )) return( FALSE );
   return( TRUE );
} // ***** Function check_entry_ulong ***** //

_________________
c/c++ for ever


Last edited by perosoft on Sat Dec 17, 2011 7:04 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: GtkEntry & numeric keypad !
PostPosted: Sun Nov 27, 2011 5:28 am 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 288
Location: Fortress of solitude
You'll need to catch every case GDK_[0..9] and GDK_KP_[0..9]...see gdk/gdkkeysyms.h

_________________
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group