Catching a mouse click inside a Gtk::Entry
- From: Christian Schaubschlaeger <cs gup uni-linz ac at>
- To: gtkmm-list gnome org
- Subject: Catching a mouse click inside a Gtk::Entry
- Date: Mon, 04 Jan 2010 15:59:59 +0100
Hello list,
I want to catch a mouse click event inside a Gtk::Entry. I tried
it with connecting to the entry's on_button_release_event() (see
code below). Unfortunately this does not work as expected: it seems
that on_button_release_event() is not emitted when I click _inside_
the entry, but only when I click on the entry's border... How can
I catch a click inside the entry?
I tried this with gtkmm-2.18.2
Thanks,
Christian
#include <iostream>
#include <gtkmm.h>
bool
on_entry_clicked(GdkEventButton *b)
{
std::cout << "Clicked\n";
return true;
}
int main(int argc, char **argv)
{
Gtk::Window *w;
Gtk::VBox *v;
Gtk::Button *b;
Gtk::Entry *e;
Gtk::Main gtk_main(argc,argv);
// new window + vbox
w = new Gtk::Window();
//w->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
w->show();
v = new Gtk::VBox();
w->add(*v);
v->show();
// quit button
b = new Gtk::Button();
v->pack_start(*b,Gtk::FILL,Gtk::FILL);
b->set_label("Quit");
b->show();
b->signal_clicked().connect(sigc::ptr_fun(Gtk::Main::quit));
// entry
e = new Gtk::Entry();
v->pack_start(*e,Gtk::FILL,Gtk::FILL);
e->show();
//e->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
e->signal_button_release_event().connect(sigc::ptr_fun(on_entry_clicked));
gtk_main.run();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]