Re: [gtkmm] Key Snooping / Key_Press_Event Howto?



Paul Davis wrote:
bool my_class::on_my_entry_key_press_event (GdkEventKey* event)
{
	const static Glib::ustring s = "0123456789";
	return (gint(s.find(event->string)) == -1);
}


this approach is severely deprecated in an age of
internationalization. you should instead do this:

   switch (ev->keyval) {
   case GDK_0:
   case GDK_1:
   ...
   case GDK_9:
        return true;
   default:
        return false;
   }


Oooo, much better (I didn't really like the string 'find' solution)!

Thanks.

Jeff




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