I fixed the problem myself. Solution(for newbies out there): signal_key_press_event().connect(sigc::mem_fun(*this,&MyClass::key_pressed),false);
Having false at the end says that default handler should handle all the events key_pressed event didn't handle. Process the events captured in key_pressed method as required and return a true or false. Returning true from key_pressed method says key_pressed method handled processing of the event. Returning false says key_pressed method didn't handle the event, default handler should handle the event. Thanks Sirisha -----Original Message----- From: [EMAIL PROTECTED] on behalf of Sirisha Muppavarapu Sent: Wed 2/21/2007 10:52 AM To: [email protected] Subject: Capture all key press events Hi All I want to capture all the keys pressed on the keyboard before sending the data to Gtk::Entry field. right now, i am doing this: signal_key_press_event().connect(sigc::mem_fun(*this, &MyClass::key_pressed)); When the focus is on the Gtk::Entry field, this method captures non alphanumeric-special characters such as F1-F12,Shift,Cntrl. I would like to capture all the keys of the keyboard before they are sent to the Entry field. Below is the code snippet. All ur inputs are highly appreciated. Thanks Sirisha MyClass.h ----------- class MyClass :: public Gtk::Window { public: MyClass(); ~MyClass(); bool on_key_pressed(GdkEventKey *event); bool getBuffer(GdkEventKey *event); protected: Gtk::Entry m_pId; }; MyClass.cpp ------------- MyClass ::MyClass() { signal_key_press_event().connect(sigc::mem_fun(*this, &MyClass::key_pressed)); show_all_children(); } bool MyClass::key_pressed(GdkEventKey *event) { bool valid = false; if(!event) valid = false; switch (event->keyval) { case F1: F1Method(); break; case F2: F2Method(); break; case F3: F3Method(); break; case F4: F4Method(); break; default: valid = getBuffer(event); break; } valid = true; } bool MyClass::getBuffer(GdkEventKey *event) { static eventCnt=0; static char buffer[256]; buffer[evenCnt++]=char(event->keycode); //do something with event and buffer return true; }
_______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
