+int shiftState, controlState;
+
+static gboolean
+TypeInProc (GtkWidget *widget, GdkEventKey *event, gpointer gdata)
+{ // This callback catches key presses on text-entries, and uses <Enter> and <Esc> as synonyms for dialog OK or Cancel
+ // *** kludge alert *** If a dialog does want some other action, like sending the line typed in the text-entry to an ICS,
+ // it should define an OK handler that does so, and returns FALSE to suppress the popdown.
+ int n = (intptr_t) gdata;
+ int dlg = n >> 16;
+ Option *opt;
+ n &= 0xFFFF;
+ opt = &dialogOptions[dlg][n];
+
+ if(opt == icsBox) return ICSKeyEvent(event->keyval); // Intercept ICS Input Box, which needs special treatment
+
+ shiftState = event->state & GDK_SHIFT_MASK;
+ controlState = event->state & GDK_CONTROL_MASK;
+ switch(event->keyval) {
+ case GDK_Return:
+ if(GenericReadout(dialogOptions[dlg], -1)) PopDown(dlg);
+ break;
+ case GDK_Escape:
+ PopDown(dlg);
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+