Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!milano!marble!cheung From: cheung@marble.sw.mcc.com (Po Cheung) Newsgroups: comp.windows.x Subject: Keyboard focus Message-ID: <2749@marble.sw.mcc.com> Date: 8 Aug 89 02:36:38 GMT Organization: MCC, Austin, TX Lines: 90 I have a simple program that pops up an asciiString widget for a user to enter text. The program works ok under twm on a Sun 3. However, when I run the same program on a DECstation 3100 running Ultrix 2.0 and the DECwindow manager, the popupshell loses the keyboard focus, and I cannot enter text at the asciiString widget. Would some kind soul please tell me what am I doing wrong? Thank you! Po Cheung (po@sw.mcc.com) ----------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #define MAXARGS 20 Widget toplevel, button, popupshell, frame, quit_button, text; void callback(), set_up(), quit_proc(); Arg args[MAXARGS]; Cardinal n; char buffer[32]; void main(argc, argv) int argc; char **argv; { toplevel = XtInitialize("toplevel", "XDemo", NULL, 0, &argc, argv); button = XtCreateManagedWidget("Button", commandWidgetClass, toplevel, args, n); XtAddCallback(button, XtNcallback, callback, NULL); set_up(); XtRealizeWidget(toplevel); XtMainLoop(); } static void callback(w, client_data, call_data) Widget w; caddr_t client_data; caddr_t call_data; { XtPopup(popupshell, XtGrabNone); } static void set_up() { n = 0; popupshell = XtCreatePopupShell("popupshell", transientShellWidgetClass, toplevel, args, n); n = 0; frame = XtCreateManagedWidget("frame", formWidgetClass, popupshell, args, n); n = 0; quit_button = XtCreateManagedWidget("QUIT", commandWidgetClass, frame, args, n); XtAddCallback(quit_button, XtNcallback, quit_proc, NULL); n = 0; XtSetArg(args[n], XtNeditType, XttextEdit); n++; XtSetArg(args[n], XtNstring, buffer); n++; XtSetArg(args[n], XtNlength, 32); n++; XtSetArg(args[n], XtNfromVert, quit_button); n++; text = XtCreateManagedWidget("", asciiStringWidgetClass, frame, args, n); XtSetKeyboardFocus(frame, text); } static void quit_proc(w, client_data, call_data) Widget w; caddr_t client_data; caddr_t call_data; { XtPopdown(XtParent(XtParent(w))); XtDestroyWidget(toplevel); exit(0); }