Re: Aw: Re: wy signal handler could not be override



In C++, declaring the method as "virtual" is needed if you want to override anything by polymorphism.

However, in Gtkmm, I never override methods. Signals do the same job and are more flexible, so I connect methods to the signals I want to handle in the constructor:

signal_button_press_event().connect(sigc::mem_fun(this, &MyClass::button_pressed));

…

bool MyClass::button_pressed(GdkEventButton* event)
{
    std::cout << "catch!" << std::endl;
    return false; // or true, see Gtk+'s doc
}


On 29/03/13 13:56, Klaus Rudolph wrote:
I've googled the thing and can't find any mistake in your function.
But to make sure you're really overriding the function, you can use the
override keyword from C++11, if your compiler supports that. For g++,
you can activate C++11 features with the -std=c++11 compiler flag (I'm
not sure if that is necessary)
You would then declare the function as follows:
virtual bool on_button_press_event(const Glib::RefPtr<Item>& target, GdkEventButton* event) override
{
cout << "catch it" << endl;
return true;
}
I use gcc 4.8.0 and 4.7.2 and used the override statement without errors. But the handler is still *not* 
called. Can anyone try to reproduce the problem? Maybe this is simply a bug?

Regards
  Klaus
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list



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