Re: Unable to pass additional argument to signal handling function



If you want to pass a widget to a signal handler, I suggest you pass a widget pointer. See e.g.
https://gitlab.gnome.org/GNOME/gtkmm-documentation/blob/gtkmm-3-24/examples/book/buildapp/step5/exampleapplication.cc line 46.

In your case:
menu_item.signal_activate().connect(sigc::bind<Gtk::Window*>(sigc::ptr_fun(&handler_fun), this));
Of course you must change handler_fun() accordingly.

I also repeat Daniel's question: Which function does not exist? If it's one of the sigc:: functions, you probably have to add an #include.
On 2019-02-18 14:39, Радомир Хаџић via gtkmm-list wrote:
I'm trying to call a function that accepts one parameter when user
clicks a menu item. I tried this:

menu_item.signal_activate().connect(sigc::bind<Gtk::Window>(sigc::ptr_fun(&handler_fun),
*this))

The method I put this code into is of class that inherits from
Gtk::Window. The handler_fun function does not belong to any class. I
saw this in official tutorial
(https://developer.gnome.org/gtkmm-tutorial/stable/sec-binding-extra-arguments.html.en)
but it doesn't work for me (the code won't compile). The error I'm
getting is that there is no such function.


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