patch for using KP_keys on gtktext
- From: Antonio Campos <acampos ceronet com>
- To: "gtk-devel-list redhat com" <gtk-devel-list redhat com>
- Subject: patch for using KP_keys on gtktext
- Date: Thu, 10 Feb 2000 13:26:13 +0100
Although I have heard that the gtktext widget is going to be deprecated,
I have
made this patch for using the KP_keys on it (againts gtk+-1.2.6)
Although it works, there are some problems (with modifiers keys):
For example, if I press: Shift+Right, then the character to the right is
selected (as expected).
But if I press: Shift+KP_Right, then I obtain a "6" (not expected, at
least for me). Then same for Shift+{KP_Left,KP_Home,KP_End,...},... and
for
Ctrl+{KP_Left,...}
I understand that when I press Shift+KP_Right (for example), the
GDK layer changes it to be "6" and not Shift+KP_Right, and that way, the
key_press_event handler of gtktext.c can't work properly.
The question is: Is there any way to avoid this? Any field in the event
data structure?
I know that it can be done, because kwrite (yes, I know, a KDE program)
does it properly.
--- ../joder/gtk+-1.2.6/gtk/gtktext.c Sat Sep 4 00:20:39 1999
+++ gtktext.c Wed Feb 9 18:47:14 2000
@@ -2002,22 +2002,29 @@
{
switch (event->keyval)
{
+ case GDK_KP_Home:
case GDK_Home:
if (event->state & GDK_CONTROL_MASK)
scroll_int (text, -text->vadj->value);
else
return_val = FALSE;
break;
+ case GDK_KP_End:
case GDK_End:
if (event->state & GDK_CONTROL_MASK)
scroll_int (text, +text->vadj->upper);
else
return_val = FALSE;
break;
+ case GDK_KP_Page_Up:
case GDK_Page_Up: scroll_int (text, -text->vadj->page_increment); break;
+ case GDK_KP_Page_Down:
case GDK_Page_Down: scroll_int (text, +text->vadj->page_increment); break;
+ case GDK_KP_Up:
case GDK_Up: scroll_int (text, -KEY_SCROLL_PIXELS); break;
+ case GDK_KP_Down:
case GDK_Down: scroll_int (text, +KEY_SCROLL_PIXELS); break;
+ case GDK_KP_Enter:
case GDK_Return:
if (event->state & GDK_CONTROL_MASK)
gtk_signal_emit_by_name (GTK_OBJECT (text), "activate");
@@ -2055,36 +2062,44 @@
switch (event->keyval)
{
+ case GDK_KP_Home:
case GDK_Home:
if (event->state & GDK_CONTROL_MASK)
move_cursor_buffer_ver (text, -1);
else
gtk_text_move_beginning_of_line (text);
break;
+ case GDK_KP_End:
case GDK_End:
if (event->state & GDK_CONTROL_MASK)
move_cursor_buffer_ver (text, +1);
else
gtk_text_move_end_of_line (text);
break;
+ case GDK_KP_Page_Up:
case GDK_Page_Up: move_cursor_page_ver (text, -1); break;
+ case GDK_KP_Page_Down:
case GDK_Page_Down: move_cursor_page_ver (text, +1); break;
/* CUA has Ctrl-Up/Ctrl-Down as paragraph up down */
+ case GDK_KP_Up:
case GDK_Up: move_cursor_ver (text, -1); break;
+ case GDK_KP_Down:
case GDK_Down: move_cursor_ver (text, +1); break;
+ case GDK_KP_Left:
case GDK_Left:
if (event->state & GDK_CONTROL_MASK)
gtk_text_move_backward_word (text);
else
move_cursor_hor (text, -1);
break;
+ case GDK_KP_Right:
case GDK_Right:
if (event->state & GDK_CONTROL_MASK)
gtk_text_move_forward_word (text);
else
move_cursor_hor (text, +1);
break;
-
+
case GDK_BackSpace:
if (event->state & GDK_CONTROL_MASK)
gtk_text_delete_backward_word (text);
@@ -2094,6 +2109,7 @@
case GDK_Clear:
gtk_text_delete_line (text);
break;
+ case GDK_KP_Insert:
case GDK_Insert:
if (event->state & GDK_SHIFT_MASK)
{
@@ -2109,6 +2125,7 @@
/* gtk_toggle_insert(text) -- IMPLEMENT */
}
break;
+ case GDK_KP_Delete:
case GDK_Delete:
if (event->state & GDK_CONTROL_MASK)
gtk_text_delete_forward_word (text);
@@ -2124,6 +2141,7 @@
position = text->point.index;
gtk_editable_insert_text (editable, "\t", 1, &position);
break;
+ case GDK_KP_Enter:
case GDK_Return:
if (event->state & GDK_CONTROL_MASK)
gtk_signal_emit_by_name (GTK_OBJECT (text), "activate");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]