Re: TreeView, Row and double click



Yes of course, very little changes for the button, i tried a bit for treeview but i prefered to test on less difficult object ;)

here is the code for the button :

#include <fenetre.h>
#include <string>
#include <iostream>
fenetre::fenetre()
{

	set_default_size(300, 300);
	set_position(Gtk::WIN_POS_CENTER);
	add(vb);	//vb is a VBox
	b.set_label("Button");  // b is a button ;)
	vb.pack_end(b, false, false);
	show_all();

	b.add_events(Gdk::BUTTON_PRESS_MASK);
b.signal_button_press_event().connect(sigc::mem_fun(*this, &fenetre::on_press));

}
bool fenetre::on_press(GdkEventButton *event)
{
	static long unsigned lastclick = 0;

std::cout << "button press event detected" << std::endl; // to test if a simple click is detected

	if (event->type == GDK_2BUTTON_PRESS && event->button ==1)
	{
		if (lastclick == 0 || (event->time - lastclick) < 600)
			lastclick = event->time;
		else
			std::cout << "Dble click" << std::endl;
		return true;

	}
	else
		return false;
}


thanks :)

_________________________________________________________________
Vidéoconférence plein écran avec MSN Messenger http://g.msn.fr/FR1001/866




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