GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

KEY pressed

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
hamid206
Familiar Face


Joined: 25 May 2007
Posts: 12

PostPosted: Wed Aug 29, 2007 5:33 am    Post subject: KEY pressed Reply with quote

I want to write a program that recognize the keys that user presses from keyboard and show that following a massage in label what function and signal should be used to distinguish and receive key types which user presses? :?: ...
Back to top
HappyCat
Familiar Face


Joined: 13 Aug 2007
Posts: 5

PostPosted: Wed Aug 29, 2007 4:17 pm    Post subject: Reply with quote

Try this

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13

gint key_press (GtkWidget *widget, GdkEventKey *event)
{
      printf("key pressed %d\n", event->keyval);
      return TRUE;
}

int main(int argc, char** argv)
{
... code for building main window ...
gtk_signal_connect (mainwin, "key-press-event", key_press, NULL);
}


The key-press-event will cause key_press to get called every time a key is pressed (I think only while the main window is in focus).
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP