[gtkmm] signal_key_press_event() question
- From: Marco <schwein chello nl>
- To: "gtkmm-list gnome org" <gtkmm-list gnome org>
- Subject: [gtkmm] signal_key_press_event() question
- Date: Thu, 07 Oct 2004 01:17:10 +0200
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]