how to get key press event in goocanvasmm

Is it possible to receive key press events in canvas?

The following signal handler is not called inside goocanvas. It compiles fine but it is not called if a key 
is pressed.


Glib::RefPtr<Goocanvas::Item> root;

class MyCanvas: public Goocanvas::Canvas
    double scale = 1;

    bool on_key_press_event( GdkEventKey* event ) override
        std::cout << "on_key_press_event" << std::endl;
        return true;


int main(int argc, char* argv[])
    Gtk::Main app(&argc, &argv);
    Goocanvas::init("example", "0.1", argc, argv);

    Gtk::Window win;

    MyCanvas m_canvas;
    m_canvas.set_size_request(640, 480);
    m_canvas.set_bounds(0, 0, 800, 800);
    root = m_canvas.get_root_item();


    Glib::RefPtr<Goocanvas::Ellipse> outer = Goocanvas::Ellipse::create( 100,100,20,20);
    outer->property_line_width() = 5;
    outer->property_stroke_color() = "red";
    root->add_child( outer );

    win.add( m_canvas);

    return 0;

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