Wrox Home  
Search P2P Archive for: Go

  Return to Index  

gtkplus_gnome thread: Query regarding key board handling


Message #1 by "girija" <girija_linux@y...> on Tue, 26 Mar 2002 09:59:37
Hi every body I am facing a problem while programming in GTK+/GNOME. My
problem can be stated like this
 Is there any method in GTK+ through whivh I can get a control over my
keyboard. So that whanaver I will press key "a" the text "GIRIJA" will be
displayed on the text entry field. I have tried a lot for this but finding
that in almost all the cases the character "a" is coming as the suffix of
the string "GIRIJA" i.e. "GIRIJAa". For your kind information I have done
the coding as follows :
  
gboolean
on_text1_key_press_event               (GtkWidget       *widget,
                                        GdkEventKey     *event,
                                        gpointer         user_data)
{
 GtkText *text; 
 const char *c="GIRIJA";
  text = lookup_widget (widget, "text1");
 if (event->length > 0)
     printf("The key event's string is `%s'\n", event->string);

   printf("The name of this keysym is `%s'\n", 
          gdk_keyval_name(event->keyval));

   switch (event->keyval)
     {
     case GDK_a:
         		
        gtk_text_insert(GTK_TEXT (text), NULL, NULL, NULL,c,-1 );
       
       
       return TRUE; 
       break;
          default:
       break;
      }
  }
 
By executing this I got the display as "GIRIJAa"**. But My intention was to
display "GIRIJA". SO I included the following function :

	 gtk_text_backward_delete(GTK_TEXT(text),1); 

Still the result comes as "GIRIJa" i.e. the character "A" got deleted from
the string.
So if you have any idea please suggest me .

Girija

  Return to Index