Re: How does 'on_key_press_event' work in 'Gtk::Entry' ?



On Sun, 2008-03-30 at 13:36 +0200, Søren Hauberg wrote:
> Hi All,
>   I'm new to GUI programming in general and specifically GTKmm, so
> bare with me...
> I'm experimenting with Gtk::Entry, and I would like the following behaviour
> 
>   If the user presses TAB, UP, or DOWN, print the key name to stdout.
>   Otherwise act as normal, that is, show the key in the text entry.
> 
> Should be simple. So my widget 'GUI_input' inherits from Gtk::Entry,
> and implements the following the 'on_key_press_event' function as
> follows:
> 
> bool GUI_input::on_key_press_event (GdkEventKey* event)
> {
>   bool handled = false;
>   switch (event->keyval)
>     {
>     case GDK_Tab:
>       std::cout << "TAB: " << std::endl;
>       handled = true;
>       break;
>     case GDK_Up:
>       std::cout << "UP: " << std::endl;
>       handled = true;
>       break;
>     case GDK_Down:
>       std::cout << "Down: " << std::endl;
>       handled = true;
>       break;
>     }
> 
>   return handled;
> }
> 
> This behaves as follows:
> 
>     If the user presses TAB, UP, or DOWN, print the key name to stdout.
>    Otherwise don't show anything in the text entry.
> 
> Can anybody give me a hint as to what I should do?

Call the Gtk::Entry's parent function if you didn't handle the event,
via 'return Gtk::Entry::on_key_press_event(event);'.

> Thanks,
> Søren

Armin

> P.S. And thanks for creating such a nice library. In general things
> are very intuitve.
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list



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