Re: Passing keypress events



Hi,

Can someone tell me how to process a keypress event to make it look like a keyboard shortcut? I'm building 
an app that has a zvtterm in it, and the zvtterm prevents keyboard shortcuts from working (because all 
shortcuts could also be used by the application in the term). Anyway, I'd like the shortcuts to be handled 
anyway, so want to catch the keypresses and then I want to send them to the menubar to process them. 
Problem is, sending them directly to the menu bar doesn't work :-( Which is the widget that handles the 
shortcuts? And can I just pass the keypress event to it with gtk_widget_event? Thanks for all hints in the 
right direction.

cheers,
 
 Catch the keypress event in your terminal widget.

 gtk_signal_connect(GTK_OBJECT(your_terminal), "key_press_event",
        GTK_SIGNAL_FUNC(keypress_cb), NULL);


void
keypress_cb(GtkWidget *widget, GdkEventKey *event)
{
        switch(event->keyval)
        {
                
                case 'c':
                        gtk_signal_emit_by_name(GTK_OBJECT(your_menu_item), "activate-item");
                        break;

/* if you want to check for control masks */
        
        if(event->state & GDK_CONTROL_MASK)
        {
                switch(event->keyval)
                {
                        case 'q':
                                quit_cb(NULL);
                                /* you can call the function directly instead of activating the
                                 * menu
                                 */
                                break;







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