RE: event data / mmoorman



What is wrong with this ?

 

     temp_button = buttons[x];   // an array of pointers

     temp_button->signal_button_press_event().connect(sigc::bind(sigc::ptr_fun(&on_button_clicked), temp_button);

     temp_button->signal_motion_notify_event().connect(sigc::bind(sigc::ptr_fun(&motion_notify_event), event);

     temp_button->signal_expose_event().connect(sigc::bind(sigc::ptr_fun(&motion_notify_event), event);

 

 

 

 

void ExampleWindow::on_button_clicked (Gtk::Button *button)

{

}

 

 

gint ExampleWindow::motion_notify_event( GdkEventMotion *event )

{

  return FALSE;

}

 

 

 

 

Error messeges:

/home/qc/gtk_tut/tlgui/examplewindow.cc|67|error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say \u2018&ExampleWindow::on_button_clicked\u2019|

/home/qc/gtk_tut/tlgui/examplewindow.cc|67|error: no matching function for call to \u2018ptr_fun(void (ExampleWindow::*)(Gtk::Button*))\u2019|

/home/qc/gtk_tut/tlgui/examplewindow.cc|68|error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say \u2018&ExampleWindow::motion_notify_event\u2019|

/home/qc/gtk_tut/tlgui/examplewindow.cc|68|error: no matching function for call to \u2018ptr_fun(gint (ExampleWindow::*)(GdkEventMotion*))\u2019|

/home/qc/gtk_tut/tlgui/examplewindow.cc|68|error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say \u2018&ExampleWindow::event\u2019|

/home/qc/gtk_tut/tlgui/examplewindow.cc|69|error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say \u2018&ExampleWindow::motion_notify_event\u2019|

/home/qc/gtk_tut/tlgui/examplewindow.cc|69|error: no matching function for call to \u2018ptr_fun(gint (ExampleWindow::*)(GdkEventMotion*))\u2019|

/home/qc/gtk_tut/tlgui/examplewindow.cc|69|error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say \u2018&ExampleWindow::event\u2019

 

 

From: Michael Moorman [mailto:memjjay yahoo com]
Sent: Thursday, December 23, 2010 6:41 PM
To: charles seedle rigaku com; gtkmm-list gnome org
Subject: Re: event data / mmoorman

 

What kind of event data are you looking for? Also, what kind of signal are you handling?

If you need to bind some extra data to your callback, try using sigc::bind.

for example:

button1.signal_clicked().connect(sigc::bind(sigc::ptr_fun(&on_button_click), &button1));
button2.signal_clicked().connect(sigc::bind(sigc::ptr_fun(&on_button_click), &button2));

....

void on_button_clicked(Gtk::Button* btn) {

}

(Did not compile the above, please forgive any syntax errors)

You could use bind in a similar way in lieu of inspecting event data for a given signal.

Michael

 

 



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