how to get key press event in goocanvasmm

"Klaus Rudolph" <[email protected]>
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <trinity-b86aeff1-3955-4ecf-b98b-852d068051ed-1581702687992@3c-app-gmx-bap07>
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.


Exmaple:


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";
    outer->property_fill_color()="blue";
    root->add_child( outer );

    win.add( m_canvas);
    win.show_all_children();


    Gtk::Main::run(win);
    return 0;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.