[gtkmm] on_key_press_event on Gtk::DrawingArea
- From: Helen Mead <h mead 180sw com>
- To: gtkmm-list gnome org
- Subject: [gtkmm] on_key_press_event on Gtk::DrawingArea
- Date: 25 Mar 2003 12:12:10 +0000
Hi,
I seem to be experiencing problems detecting keyboard events on a
Gtk::DrawingArea. The "on_button_press_event" event picks up mouse
clicks on the drawing area, but the "on_key_press_event" doesn't appear
to detect keyboard events.
I have attached some example code.
Thanks,
--
Helen
=====================================================================
Helen Mead Software Engineer
OneEighty Software Ltd. Phone: +44 20 8680 8712
Cygnet House Fax: +44 20 8680 8453
12-14 Sydenham Road
Croydon Email: h mead 180sw com
CR9 2ET
UK
Under the Regulation of Investigatory Powers (RIP) Act 2000 together
with any and all Regulations in force pursuant to the Act One Eighty
Software Ltd reserves the right to monitor any or all incoming or
outgoing communications as provided for under the Act.
#include <gtkmm/drawingarea.h>
#include <gtkmm.h>
#include <gdk/gdk.h>
class TestDrawingArea : public Gtk::DrawingArea {
public:
TestDrawingArea();
virtual ~TestDrawingArea();
protected:
virtual void on_realize();
virtual bool on_expose_event(GdkEventExpose* event);
virtual bool on_key_press_event(GdkEventKey* event);
virtual bool on_button_press_event(GdkEventButton* event);
};
TestDrawingArea::TestDrawingArea() {
this->add_events(Gdk::KEY_PRESS_MASK
| Gdk::BUTTON_PRESS_MASK);
}
TestDrawingArea::~TestDrawingArea() {
}
void TestDrawingArea::on_realize() {
g_print("%s\n", __FUNCTION__);
Gtk::DrawingArea::on_realize();
}
bool TestDrawingArea::on_expose_event(GdkEventExpose *event) {
g_print("%s\n", __FUNCTION__);
return true;
}
/**
* This event doesn't appear to get called in response to keyboard events
*/
bool TestDrawingArea::on_key_press_event(GdkEventKey* event) {
g_print("%s\n", __FUNCTION__);
return true;
}
bool TestDrawingArea::on_button_press_event(GdkEventButton* event) {
g_print("%s\n", __FUNCTION__);
return true;
}
int main (int argc, char *argv[]) {
Gtk::Main kit(argc, argv);
Gtk::Window window;
TestDrawingArea *testDrawingArea;
testDrawingArea = manage(new TestDrawingArea());
window.add(*testDrawingArea);
window.show_all_children();
Gtk::Main::run(window);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]