Re: EventBox and bind combination



On Thu, 2005-02-03 at 16:24 -0600, Bob Caryl wrote:
> Your problem is that you neglected to indicate to the template what
> sort of value you were passing, i.e.
> 
> m_EventBox.signal_button_press_event().connect(sigc::bind<char
> *>(sigc::mem_fun(*this,&ExampleWindow::button_press), "testing"));

I'm not quite sure whether that should work with libsigc++ 2. 
sigc::bind<-1, const char*> should work. A Glib::ustring would be better
too.

> 
> Give that a try... 
> 
> Cheers!
> 
> Bob Caryl 
> On Thu, 2005-02-03 at 15:41, Pete S wrote: 
> > Hello,
> > 
> > I've been programming with gtkmm for a little while
> > and I really enjoy it.  I was wondering if any of you
> > might have suggestions on how to overcome the
> > following hurdle:
> > 
> > I'm trying to pass a parameter into a on_button_press
> > function as follows:
> > <begin code>
> > m_EventBox.signal_button_press_event().connect(sigc::bind(sigc::mem_fun(*this,
> > &ExampleWindow::button_press), "testing") );
> > <end code>
> > 
> > with button_press() being defined as follows:
> > <begin code>
> > //eventbox.h file
> > class ExampleWindow {
> > ...
> > bool button_press(GdkEventButton *e, char *t);
> > ...
> > };
> > 
> > //eventbox.cc file
> > bool ExampleWindow::button_press(GdkEventButton*, char
> > *t);
> > {
> > cout<<t<<"\n";
> > return true;
> > }
> > 
> > <end code>
> > 
> > If I decide not to use sigc::bind and remove the char
> > *t from button_press(), it compiles and works fine,
> > but I need to know how to pass a parameter when the
> > EventBox press button signal is emitted.
> > 
> > Here's what the compilation output looks like:
> > <begin comp output>
> > $ make -f eventbox.mak 
> > g++ -g `pkg-config gtkmm-2.4 --cflags --libs` -o
> > eventbox eventbox.cc eventboxmain.cc -L/usr/local/lib
> > -pthread 
> > /usr/local/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:
> > In member function `typename
> > sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1,
> > T_arg2, void, void, void, void, void>::type
> > sigc::adaptor_functor<T_functor>::operator()(T_arg1,
> > T_arg2) const [with T_arg1 = GdkEventButton* const&,
> > T_arg2 = Glib::ustring&, T_functor =
> > sigc::bound_mem_functor2<bool, ExampleWindow,
> > GdkEventButton*, char*>]':
> > /usr/local/include/sigc++-2.0/sigc++/adaptors/bind.h:1121:
> >   instantiated from `typename
> > sigc::bind_functor<-0x000000001, T_functor, T_type1,
> > sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> > sigc::nil>::deduce_result_type<T_arg1, void, void,
> > void, void, void, void>::type
> > sigc::bind_functor<-0x000000001, T_functor, T_type1,
> > sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> > sigc::nil>::operator()(T_arg1) [with T_arg1 =
> > GdkEventButton* const&, T_functor =
> > sigc::bound_mem_functor2<bool, ExampleWindow,
> > GdkEventButton*, char*>, T_type1 = Glib::ustring]'
> > /usr/local/include/sigc++-2.0/sigc++/functors/slot.h:136:
> >   instantiated from `static T_return
> > sigc::internal::slot_call1<T_functor, T_return,
> > T_arg1>::call_it(sigc::internal::slot_rep*, typename
> > sigc::type_trait<T_arg3>::take) [with T_functor =
> > sigc::bind_functor<-0x000000001,
> > sigc::bound_mem_functor2<bool, ExampleWindow,
> > GdkEventButton*, char*>, Glib::ustring, sigc::nil,
> > sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> > sigc::nil>, T_return = bool, T_arg1 =
> > GdkEventButton*]'
> > /usr/local/include/sigc++-2.0/sigc++/functors/slot.h:144:
> >   instantiated from `static void*(*
> > sigc::internal::slot_call1<T_functor, T_return,
> > T_arg1>::address())(void*) [with T_functor =
> > sigc::bind_functor<-0x000000001,
> > sigc::bound_mem_functor2<bool, ExampleWindow,
> > GdkEventButton*, char*>, Glib::ustring, sigc::nil,
> > sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> > sigc::nil>, T_return = bool, T_arg1 =
> > GdkEventButton*]'
> > /usr/local/include/sigc++-2.0/sigc++/functors/slot.h:524:
> >   instantiated from `sigc::slot1<T_return,
> > T_arg1>::slot1(const T_functor&) [with T_functor =
> > sigc::bind_functor<-0x000000001,
> > sigc::bound_mem_functor2<bool, ExampleWindow,
> > GdkEventButton*, char*>, Glib::ustring, sigc::nil,
> > sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> > sigc::nil>, T_return = bool, T_arg1 =
> > GdkEventButton*]'
> > /usr/local/include/sigc++-2.0/sigc++/functors/slot.h:1129:
> >   instantiated from `sigc::slot<T_return, T_arg1,
> > sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> > sigc::nil>::slot(const T_functor&) [with T_functor =
> > sigc::bind_functor<-0x000000001,
> > sigc::bound_mem_functor2<bool, ExampleWindow,
> > GdkEventButton*, char*>, Glib::ustring, sigc::nil,
> > sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> > sigc::nil>, T_return = bool, T_arg1 =
> > GdkEventButton*]'
> > eventbox.cc:37:   instantiated from here
> > /usr/local/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:103:
> > error: no match for call to
> > `(sigc::bound_mem_functor2<bool, ExampleWindow,
> > GdkEventButton*, char*>) (GdkEventButton* const&,
> > Glib::ustring&)'
> > /usr/local/include/sigc++-2.0/sigc++/functors/mem_fun.h:1897:
> > note: candidates are: T_return
> > sigc::bound_mem_functor2<T_return, T_obj, T_arg1,
> > T_arg2>::operator()(typename
> > sigc::type_trait<T_arg3>::take, typename
> > sigc::type_trait<T_arg4>::take) const [with T_return =
> > bool, T_obj = ExampleWindow, T_arg1 = GdkEventButton*,
> > T_arg2 = char*]
> > make: *** [eventbox] Error 1
> > <end comp output>
> > 
> > Sorry for the mess and thanks for any/all suggestions.
> > 
> > Pete
> > _______________________________________________
> > gtkmm-list mailing list
> > gtkmm-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtkmm-list
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




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