Update of /cvsroot/htoolkit/port/src/cbits/GTK
In directory sc8-pr-cvs1:/tmp/cvs-serv13973/port/src/cbits/GTK
Modified Files:
Window.c
Log Message:
Proper event handling for dialogs
Index: Window.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Window.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Window.c 26 Apr 2003 20:03:06 -0000 1.15
--- Window.c 27 Apr 2003 18:19:14 -0000 1.16
***************
*** 320,323 ****
--- 320,405 ----
}
+ static gboolean dialog_key_press_handler(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+ {
+ int c;
+ int modifiers = 0;
+
+ widget = GTK_BIN(widget)->child;
+
+ if (event->state & GDK_SHIFT_MASK) modifiers |= shiftBIT;
+ if (event->state & GDK_CONTROL_MASK) modifiers |= ctrlBIT;
+ if (event->state & GDK_MOD1_MASK) modifiers |= altBIT;
+
+ if (event->length > 0)
+ {
+ c = event->string[0];
+ if (modifiers & altBIT) c += 256;
+ }
+ else
+ c = CheckVirtualKeyCode(event->keyval);
+
+ if (!c) return gtk_false();
+
+ if (gInKey)
+
+ {
+ if (gCurChar == c)
+ handleWindowKeyboard(widget, evKeyStillDown, gCurChar, modifiers);
+ else
+ {
+ handleWindowKeyboard(widget, evKeyUp, gCurChar, modifiers);
+ gCurChar = c;
+ handleWindowKeyboard(widget, evKeyDown, gCurChar, modifiers);
+ }
+ }
+ else
+ {
+ gCurChar = c;
+ handleWindowKeyboard(widget, evKeyDown, gCurChar, modifiers);
+ gInKey = TRUE;
+ }
+
+ return gtk_false();
+ };
+
+ static gboolean dialog_key_release_handler(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+ {
+ if (gInKey)
+ {
+ int modifiers = 0;
+
+ widget = GTK_BIN(widget)->child;
+
+ if (event->state & GDK_SHIFT_MASK) modifiers |= shiftBIT;
+ if (event->state & GDK_CONTROL_MASK) modifiers |= ctrlBIT;
+ if (event->state & GDK_MOD1_MASK) modifiers |= altBIT;
+
+ handleWindowKeyboard(widget, evKeyUp, gCurChar, modifiers);
+ gInKey = FALSE;
+ gCurChar = 0;
+ }
+
+ return gtk_false();
+ };
+
+ static void dialog_focus_in_handler(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+ {
+ handleDialogActivate(GTK_BIN(widget)->child);
+ }
+
+ static void dialog_focus_out_handler(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+ {
+ if (gInKey)
+ {
+ handleWindowKeyboard(GTK_BIN(widget)->child, evKeyUp, gCurChar, 0);
+
+ gInKey = FALSE;
+ gCurChar = 0;
+ }
+
+ handleDialogDeactivate(GTK_BIN(widget)->child);
+ }
+
+
WindowHandle osCreateDialog(WindowHandle parent)
***************
*** 331,336 ****
frame = gtk_window_new (GTK_WINDOW_TOPLEVEL);
! gtk_window_set_transient_for(frame, gtk_widget_get_toplevel(parent));
! gtk_window_set_destroy_with_parent(frame, gtk_true());
sw = create_generic_window();
--- 413,432 ----
frame = gtk_window_new (GTK_WINDOW_TOPLEVEL);
! gtk_window_set_transient_for(GTK_WINDOW(frame), GTK_WINDOW(gtk_widget_get_toplevel(parent)));
! gtk_window_set_destroy_with_parent(GTK_WINDOW(frame), gtk_true());
!
!
! gtk_signal_connect (GTK_OBJECT(frame), "key-press-event",
! GTK_SIGNAL_FUNC(dialog_key_press_handler),
! NULL);
! gtk_signal_connect (GTK_OBJECT(frame), "key-release-event",
! GTK_SIGNAL_FUNC(dialog_key_release_handler),
! NULL);
! gtk_signal_connect (GTK_OBJECT(frame), "focus-in-event",
! GTK_SIGNAL_FUNC(dialog_focus_in_handler),
! NULL);
! gtk_signal_connect (GTK_OBJECT(frame), "focus-out-event",
! GTK_SIGNAL_FUNC(dialog_focus_out_handler),
! NULL);
sw = create_generic_window();
|