[Xfc-dev] Signal-handling-question

Jeff Franks jcfranks at tpg.com.au
Tue Jul 26 05:45:37 CEST 2005


Johannes Zellner wrote:

>Hi
>
>I started to write a small application with the foundation-classes, now 
>I've a question:
>How can I connect the key_release_signal to a Entry-Widget ?
>
>I tried it like:
>
>entry->signal_key_release_event().connect(sigc::mem_fun(this, 
>&FileStepper::gofor));
>
>.....
>
>
>bool gofor(Gdk::EventCrossing& event)
>{
>....
>}
>
>But I get many confusin errors by compiling.
>
>Would be nice if someone could just post a example :-)
>
>  
>
Johannes,

I don't know if this is your problem but the example code above is 
wrong. FileStepper::gofor() is declared as a class member function but 
it's defined as a global function. You shouldn't use global functions in 
C++ if you can avoid it, but if you did, the above code should look like 
this:

entry->signal_key_release_event().connect(sigc::ptr_fun(&gofor));

bool gofor(Gdk::EventCrossing& event)
{
....
}

and  for a member function the code should look like this:

entry->signal_key_release_event().connect(sigc::mem_fun(this, 
&FileStepper::gofor));

bool FileStepper::gofor(Gdk::EventCrossing& event)
{
....
}

I presume "this" is a FileStepper instance. If not, "this" should point 
to the class the gofor() function is declared in.

Jeff.




More information about the Xfc-dev mailing list