Re: Gtk::Image and mouse click



Petr,

This type of error is generally caused by your call back not having the appropriate signature.

In your case it should be:

bool
MainWindow::on_image2_button_press( GdkEvent* event ) ;

And another gotchya to remember is to enable mouse events to be captured by the widget. I'm not sure that Gtk::Image has them on by default.

But its something like:

Gdk::EventMask events = image.get_events() ;
events |= Gdk::BUTTON_PRESS_MASK ;
image.set_events( events ) ;

Or, you can wrap your image in an event box and connect your call back to the event box.

Paul

Petr Hracek wrote:

Hi everybody,
I want to click on the image widget and get coors.
I used following:
Gtk::Image image;
image.signal_button_press_event().connect(sigc::mem_fun(*this, &MainWindow::on_image2_button_press));
but it shows me error message:

/usr/include/sigc++-2.0/sigc++/functors/slot.h: In static member function ‘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::bound_mem_functor0<void, MainWindow>, T_return = bool, T_arg1 = GdkEventButton*]’: /usr/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::bound_mem_functor0<void, MainWindow>, T_return = bool, T_arg1 = GdkEventButton*]’ /usr/include/sigc++-2.0/sigc++/functors/slot.h:529: instantiated from ‘sigc::slot1<T_return, T_arg1>::slot1(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, MainWindow>, T_return = bool, T_arg1 = GdkEventButton*]’ /usr/include/sigc++-2.0/sigc++/functors/slot.h:1157: 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::bound_mem_functor0<void, MainWindow>, T_return = bool, T_arg1 = GdkEventButton*]’
MainWindow.cpp:198: instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/slot.h:137: error: void value not ignored as it ought to be /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h: In member function ‘typename sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1, void, void, void, void, void, void>::type sigc::adaptor_functor<T_functor>::operator()(T_arg1) const [with T_arg1 = GdkEventButton* const&, T_functor = sigc::bound_mem_functor0<void, MainWindow>]’: /usr/include/sigc++-2.0/sigc++/functors/slot.h:137: 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::bound_mem_functor0<void, MainWindow>, T_return = bool, T_arg1 = GdkEventButton*]’ /usr/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::bound_mem_functor0<void, MainWindow>, T_return = bool, T_arg1 = GdkEventButton*]’ /usr/include/sigc++-2.0/sigc++/functors/slot.h:529: instantiated from ‘sigc::slot1<T_return, T_arg1>::slot1(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, MainWindow>, T_return = bool, T_arg1 = GdkEventButton*]’ /usr/include/sigc++-2.0/sigc++/functors/slot.h:1157: 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::bound_mem_functor0<void, MainWindow>, T_return = bool, T_arg1 = GdkEventButton*]’
MainWindow.cpp:198: instantiated from here
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:84: error: no match for call to ‘(sigc::bound_mem_functor0<void, MainWindow>) (GdkEventButton* const&)’ /usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1786: note: candidates are: T_return sigc::bound_mem_functor0<T_return, T_obj>::operator()() const [with T_return = void, T_obj = MainWindow] /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:84: error: return-statement with a value, in function returning 'void'

can you help me with this problem?
regards
Petr Hracek

------------------------------------------------------------------------

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



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