Re: Key pressed and modifier



gtk gtk wrote:
Hi!

I'm a new user of gtk/gdk and I can't cope with the
following problem. I need to handle the event
<control>m.  Here is the way I connect this signal to
my widget:

  SIGNAL_CONNECT(GTK_OBJECT(my_widget),
                 "key-press-event",
                 GTK_SIGNAL_FUNC(key_pressed_handler),
                 NULL);

and the associated handler:

void key_pressed_handler(GtkWidget *widget, GdkEventKey *event,
                         gpointer func_data _U_)
{
   /* Ctrl M on the line */
   if (event->type == GDK_KEY_PRESS)
   {
      if ((event->state == GDK_MOD2_MASK) &&

if ((event->state == GDK_CONTROL_MASK) &&

Correction:

if ((event->state & GDK_CONTROL_MASK) &&

          ((event->keyval == GDK_m) || (event->keyval
== GDK_M)))
      {
         <my_treatment>
      }
   }
}

The problem is that I get nothing when I run this... I
tried with "m" only (without <control>) and it's ok.
What can I do so as the <control> modifier is taken
into account?





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