events - Detect click on Gtk::Image? -


i've been trying detect clic on gtk::image gtkmm on 2 hours, couldn't work. compile , excecute fine, event never triggered.

some stuff tried, compiles, not crash, doens't work:

m_image = manage(new gtk::image(gtk::stock::apply, gtk::icon_size_button)); m_image->add_events(gdk::all_events_mask);  m_hbox->pack_start(*m_image, gtk::pack_shrink);  m_image->signal_button_release_event()     .connect(sigc::hide(sigc::mem_fun(*this, &todo::switchstatus)));  m_image->show(); 

or

#include <gtkmm/main.h> #include <gtkmm/window.h> #include <gtkmm/button.h> #include <gtkmm/stock.h> #include <gtkmm/image.h>  #include <iostream>  using namespace std;  class win : public gtk::window {     public:         win();         bool link(gdkeventbutton* e);      private:         gtk::image image; };  win::win()     : image(gtk::stock::apply, gtk::icon_size_button) {     cerr << "created" << endl;      image.add_events(gdk::button_press_mask | gdk::button_release_mask);     image.signal_button_release_event().connect(sigc::mem_fun(*this, &win::link));     image.show();      add(image); }  bool win::link(gdkeventbutton* e) {     cerr << "kuh" << endl; }  int main(int argc, char *argv[]) {     gtk::main   app(argc, argv);      gtk::window window;     window.resize(300, 500);      win win;      gtk::main::run(win);      return 0; } 

well, don't know else can dow… idea ? :)

thanks in advance.

from http://developer.gnome.org/gtkmm/unstable/classgtk_1_1image.html:

gtk::image "no window" widget (has no gdk::window of own), default not receive events. if want receive events on image, such button clicks, place image inside gtk::eventbox, connect event signals on event box

so guess try put signal on eventbox after wrapping image eventbox.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -