Gtk::EventBox signal_button_press_event() for Gtk::Image...




What I wanna do is just to "respond" the "click" on an "image". Make sure I
don't actually need a "Button".

As explained in
http://gtkmm.sourceforge.net/gtkmm2/docs/reference/html/classGtk_1_1Image.html#a2

"Gtk::Image is a "no window" widget (has no Gdk::Window of its own), so by
default does not receive events. If you want to receive events on the image,
such as button clicks, place the image inside a Gtk::EventBox, then connect
to the event signals on the event box."

Thus, I have my code:

Gtk::Image *m_Image; // "no window" widget to load an image
Gtk::EventBox m_imagebox; // Gtk::EventBox connecting between the event
signals and the image widget
Gtk::Window  m_imagewindow; // A window to display the image, also where the
event could happen on

m_Image = new Gtk::Image (filename); // filename is known already
m_imagebox.add(*m_Image); // add the loaded image  to the EventBox
(something like a pack-up)
m_imagewindow.add (m_imagebox); // add the EventBox to the window to be
displayed (just for display)
m_imagebox.show(); // show the imagebox, is it required? maybe required for 
m_Image->show (); // show the image.

m_imagebox.set_events(Gdk::BUTTON_PRESS_MASK); // mask the respond event,
say, "press a button"

m_imagebox.signal_button_press_event().connect(sigc::mem_fun(*this,            
&CLabeling::on_button_label_onepoint) );

m_imagewindow.show(); // show the window

Whenever I compile the file, I got the following errors:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:84: error: no match
for call to ‘(sigc::bound_mem_functor1<bool, CMyOwnClass, GdkEventKey*>)
(GdkEventButton* const&)'

I struggled on this problem for several days. I really need your help!!!

I thought the reason might be Gtk::EventBox doesn't overload
signal_button_press_event()??

My OS is Ubuntu 7.04 Feisty 64bit, with libgtkmm-2.4-1c2a, libgtkmm-2.4-dev
installed .

Can anybody give me a hand? Seriously Urgent!!!

Thank you very much.

JIA Pei




-- 
View this message in context: http://www.nabble.com/Gtk%3A%3AEventBox-signal_button_press_event%28%29-for-Gtk%3A%3AImage...-tf4374676.html#a12469653
Sent from the Gtkmm mailing list archive at Nabble.com.




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