[Gtk-sharp-list] left mousebutton double-click

Crucius, Wesley WCrucius at sandc.com
Tue Apr 18 10:05:29 EDT 2006


You'll need to look at the arg(s) "passed" to your button_press event handler.
What you want to check for is the 'Gdk.EventType.TwoButtonPress' value.
Also, note that a double click actually generates multiple events...  
This talks about the events sequencing:
http://www.go-mono.com/docs/index.aspx?tlink=5@ecma%3a713%23ButtonPressEventHandler%2f

You'll have to look at the "array" of GLib.SignalArgs.Args, which I think is intended to deal with event queueing, although I don't think I've ever seen more that one event in the list, but I guess that depends on how fast you are processing them.  You'll want some logic similar to this, I believe:
(Note that handler is hooked to widget_event instead of button_event, so it will catch key_press events and even mouse_move events, which I was interested in for my application)

   void OnWidgetEvent(object o, GLib.SignalArgs args)  //HANDLES ALL WIDGET EVENTS
   {
     Gdk.Event gdkEvent;

      Gtk.Widget wdgt = (Gtk.Widget) o;

      //Console.WriteLine("on_widget_event has fired...");
      foreach(object argObj in args.Args)
      {
         // For now, we'll filter ALL Widget events except the ones that we (plan/know_how) to handle
         System.Type sysType = argObj.GetType();   
         if( (sysType == typeof(Gdk.EventButton))
         ||  (sysType == typeof(Gdk.EventKey)) )
         {
            gdkEvent = (Gdk.Event) argObj;
            switch(gdkEvent.Type)
            {
               case Gdk.EventType.ButtonPress:
                  // handle the event as desired here...
                  break;

               case Gdk.EventType.TwoButtonPress:
                  // handle the event as desired here...
                  break;

               case Gdk.EventType.ThreeButtonPress:
                  // handle the event as desired here...
                  break;

               case Gdk.EventType.ButtonRelease:
                  // handle the event as desired here...
                  break;
            
               case Gdk.EventType.KeyPress:
                  // handle the event as desired here...
                  break;

               case Gdk.EventType.KeyRelease:
                  // handle the event as desired here...
                  break;
            }
         }
      }
   }


Hope this helps...
Wes

-----Original Message-----
From: gtk-sharp-list-bounces at lists.ximian.com [mailto:gtk-sharp-list-bounces at lists.ximian.com] On Behalf Of Thomas Zühlke
Sent: Tuesday, April 18, 2006 2:24 AM
To: gtk-sharp-list at lists.ximian.com
Subject: [Gtk-sharp-list] left mousebutton double-click

Hi *,

I have a Gtk.DrawingArea and I want to recognize a normal double-click with the left mousebutton. On the Mono-Doc helppage: 
http://www.go-mono.com/docs/index.aspx?tlink=5@ecma%3a713%23ButtonPressEventHandler%2f
for ButtonPressEvent is nothing written (not documented yet).
I have connected to the ButtonPressEvent and I know the pressed button with "args.Event.Button == 1", but there seems to be no way to detect a one-click or a double-click event?!

Thx, Thomas
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com http://lists.ximian.com/mailman/listinfo/gtk-sharp-list




More information about the Gtk-sharp-list mailing list