Re: [gtkmm] signal_key_press_event() question



thanks for your reply,

I tried almost the same:
    return on_key_press_event(event);  //this of course resulted in an
endless loop
instead of
    return Gtk::Entry::on_key_press_event(event);
I think this will bypass my NumberEntry::on_key_press_event() and thus avoid
the endless loop, (i still have to learn some things about c++).
I will try this.

thank you,
Marco

----- Original Message ----- 
From: "Daniel J. Lauk" <Daniel Lauk Student FH-Reutlingen de>
To: <schwein chello nl>;
<"gtkmm-list gnome org"@loginmail.fh-reutlingen.de>; <gtkmm-list gnome org>
Sent: Thursday, October 07, 2004 9:10 AM
Subject: Re: [gtkmm] signal_key_press_event() question


> Hi.
>
> First of all, I think, that your Gdk event handler is not doing all it
should,
> but I'm not sure.
> Anyway, what you'd probably like is, to have the same behaviour as with a
regular
> Gtk::Entry except for the thing with the <ENTER> to <TAB> conversion,
right?
>
> I'm not absolutely sure on this, but you might like to experiment with the
following
> code:
>
> <code>
> bool NumberEntry::on_key_press_event(GdkEventKey* event)
> {
>   /* first (if necessary) change the key code */
>   //36 = enter, 108 = keypad enter, 13 = tab
>   if (event->hardware_keycode==36 ||
>       event->hardware_keycode==108)
>   {
>     event->hardware_keycode = 13;
>   }
>
>   /* and now do, what Gtk::Entry would have done */
>   return Gtk::Entry::on_key_press_event(event);
> }
> </code>
>
> Best regards,
>
> DJ
>
> >I want to catch a keypress of enter and turn it into a tab (to go to the
> >next entry) to enable the user to quickly enter lots of numbers with the
> >numerical keypad.
> >
> >Then i tried this code to catch a keypress in a Gtk::Entry, but this only
>
> >works with non-printable keys (tab, function keys etc.)
> >So i think that all printable characters get processed by the entry's
> >on_key_press_event() and never make it to OnKeyPress() ?.
> >
> >class NumberEntry : public Gtk::Entry
> >{ public:
> > NumberEntry();
> > ~NumberEntry();
> > bool OnKeyPress(GdkEventKey* event);
> >};
> >
> >NumberEntry::NumberEntry()
> >{ signal_key_press_event().connect(sigc::mem_fun(*this,
> >&NumberEntry::OnKeyPress));
> >}
> >
> >bool NumberEntry::OnKeyPress(GdkEventKey* event)
> >{ cout << "Pressed " << event->hardware_keycode << endl;
> > return false;
> >}
> >
> >
> >I also tried overriding the on_key_press_event() function and was able to
>
> >turn an enter into a tab, however no printable characters made it into
the
>
> >entry box.
> >
> >bool NumberEntry::on_key_press_event(GdkEventKey* event)
> >{ cout << "Pressed " << event->hardware_keycode << endl;
> > //36 = enter, 108 = keypad enter, 13 = tab
> > if (event->hardware_keycode==36 || event->hardware_keycode==108)
> > { event->hardware_keycode = 23;
> > return on_key_press_event(event); //tab to next
> > }
> > return false;
> >}
> >
> >i'm kinda stuck now, what am i doing wrong?, or is there maybe a much
> >simpler way to achieve what i want?
> >
> >thanks for any help,
> >Marco
> _______________________________________________
> 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]