Signal Handling problem



 
----- Original Message -----
Sent: Friday, April 11, 2003 2:14 PM
Subject: (no subject)

Hi list,
 
    I have a question regarding signal handling in GTK 2.2
 
As fas as I know, Gtk has its default handler for key press event, If I connect the signal key-press-event with my user defined handler then it kind of wraps the default handler and whenever key-press-event is occured, my default handler gets called. My specific problem is :
 
In my text editor, I want to check whether I can find out the pressed key is '\n' or not, if it is '\n' then I do some linked list specific tasks. for this, in main gui function, I look for key-press-event signal and associate it with my own handler which does the task of identifying the key with the help of eventKey->keyval structure parameter. But the problem that I am facing is, everytime i press any keys my handler associated with key-press-event signal gets called and I can not print normal characters on the text view as normal text editor does. I need to stop the emission of this key-press-event signal in my handler so that i can type in the text view freely.
 
Please provide me what should be necessary to do ? which function should i use to stop the emission of key-press-event in my handler?
 
following is my code:
===============
 
static void init_gui()
{
   GtkWidget *text; /* text is nothing but text_view object */
   /* Text_view is created and displayed in th GUI */
   g_signal_connect(GTK_OBJECT(GTK_WIDGET(text)), "key-press-event", GTK_SIGNAL_FUNC(detectEnter),NULL);
}
 
My handler
========
gboolean detectEnter(GtkWidget *w, GdkEventKey *key, gpointer data)
{
       switch(key->keyval)
       {
            case GDK_Return : /* case for detection of enter key and linked list specific tasks */
                                           ret = TRUE;
            case GDK_Down : /* down key is pressed */
            case GDK_Up: /* up key is pressed */
            default: break;
       }
       return ret;
}
 
please tell me where should i stop emission of key-press-event so that I can type in freely and my handler will not be called everytime i type any keys.
 
Waiting for reply as earliest,
 
Vikram


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