Refined previous update so that arrow keys and other navigation keys aren't redirected
authorfliep <fliep@ddfedd41-794f-dd11-ae45-00112f111e67>
Sun, 1 Mar 2009 22:39:25 +0000 (22:39 +0000)
committerfliep <fliep@ddfedd41-794f-dd11-ae45-00112f111e67>
Sun, 1 Mar 2009 22:39:25 +0000 (22:39 +0000)
src/input.c
src/window.c

index 22f321cc1488a672ea66078cf56296989febd8c1..bcd5116757446413bcd6d48005e8b52c483eca74 100644 (file)
@@ -236,10 +236,20 @@ on_window_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)
        /* If this is a text grid window, and line input is active, then redirect the key press to the line input GtkEntry */
        if( win->type == wintype_TextGrid && (win->input_request_type == INPUT_REQUEST_LINE || win->input_request_type == INPUT_REQUEST_LINE_UNICODE) )
        {
-               gboolean retval = TRUE;
-               g_signal_emit_by_name(win->input_entry, "key-press-event", event, &retval);
+               if(event->keyval == GDK_Up || event->keyval == GDK_KP_Up
+                   || event->keyval == GDK_Down || event->keyval == GDK_KP_Down
+                   || event->keyval == GDK_Left || event->keyval == GDK_KP_Left
+                   || event->keyval == GDK_Right || event->keyval == GDK_KP_Right
+                   || event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab
+                   || event->keyval == GDK_Page_Up || event->keyval == GDK_KP_Page_Up
+                   || event->keyval == GDK_Page_Down || event->keyval == GDK_KP_Page_Down
+                   || event->keyval == GDK_Home || event->keyval == GDK_KP_Home
+                   || event->keyval == GDK_End || event->keyval == GDK_KP_End)
+                       return FALSE; /* Don't redirect these keys */
                gtk_widget_grab_focus(win->input_entry);
                gtk_editable_set_position(GTK_EDITABLE(win->input_entry), -1);
+               gboolean retval = TRUE;
+               g_signal_emit_by_name(win->input_entry, "key-press-event", event, &retval);
                return retval; /* Block this key event if the entry handled it */
        }
        if(win->input_request_type != INPUT_REQUEST_CHARACTER && 
index 8351378363e343a1450b40469a6647958e531ad7..204daa566c8868714d98d18e5ddf9a856f20b8e2 100644 (file)
@@ -385,7 +385,7 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype,
         }
         win->width = (glui32)(win->widget->allocation.width / win->unit_width);
         win->height = (glui32)(win->widget->allocation.height / win->unit_height);
-                
+               
         /* Mark the cursor position */
         GtkTextIter begin;
         GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );