I tried to detect clic on Gtk::Image with gtkmm for more than 2 hours, but I could not get it to work. It compiles and cancels the penalty, but the event never fires.
Some things that I tried that compiled do not crash but do not 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, I donβt know what else I can do ... Any ideas? :)
Thanks in advance.
source share