how do I catch double clicks

2005-06-03 Thread John Taber
How do I catch a mouse double click?  I couldn't find any class documentation 
on GdkEventButton and the associated event-type enums  and 
event-type==GDK_MOUSE_DOUBLE_PRESS did not work.  thks.
___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: how do I catch double clicks

2005-06-03 Thread Claudio Polegato Junior

John Taber escreveu:

How do I catch a mouse double click?  I couldn't find any class documentation 
on GdkEventButton and the associated event-type enums  and 
event-type==GDK_MOUSE_DOUBLE_PRESS did not work.  thks.
 



Hi,

To catch the single and double click, you can use this:

// The click timeout in ms
#define CLICK_TIMEOUT 250

bool On_Time = false;

bool Object::On_Click(GdkEventButton* Event){
   if (On_Time){
   Time.disconnect();
   On_Time = false;
   // Paste here the code to double click
  }
   else{
   // Activate the timeout
   On_Time = true;
   Time = Glib::signal_timeout().connect(SigC::slot(*this, 
Object::Time_Click), CLICK_TIMEOUT); // This is on GTKmm

 }
   }
   return true;   // false - stop event  /  true - continue event
}

bool Object::Time_Click(){
   On_Time = false;
// Paste here the code to single click
   return false;
}

Now, if you need just a double click, use:

bool Object::On_Double_Click(GdkEventButton* Event){
   if (Event-GdkEventType == GDK_2BUTTON_PRESS){
   // Paste here the code to double click
  }
   return true;   // false - stop event  /  true - continue event
}

The On_Click function must be connected on object's signal 
button_press_event and the declarations must be corrects.
Note on the second case, the triple click also emit GDK_2BUTTON_PRESS, 
so the function On_Double_Click will run two times.

See the GdkEventButton on GTK+ manual (or documentation) to learn more.

--

[]'s

Claudio Polegato Junior

Um peregrino de Problemas; Um pergaminho de Soluções.

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list