muenx@heike.informatik.uni-dortmund.de (Holger Muenx) (06/26/90)
Hi! I'm starting programming with X-Windows and Motif. I have two problems: 1. Is it possible to activate a XmText-Widget without clicking with the mouse into it? I imagine the following: I have an application with different Text-Widgets. If I press the <Return> key in one widget the next text widget should automatically be activated so that the user can continue typing in it without moving the mouse. I think it is a good idea to minimize the user's mouse-movement operations. To do this I need a procedure to activate a widget. Is such thing avaible? 2. I have written an application which uses different windows. I create a new window using the XmBulletinBoard-class. Text-Widgets in my main-window call their callback without any problem. Text-Widget in BulletinBoards refuse to call their callback. What's my mistake? See the sample code below my signature. It created two text-widgets, one in the main-window and one in the new BulletinBoard. Thanks in advance, -Holger =========================================================================== || Holger Muenx, IRB, Universitaet Dortmund, 4600 Dortmund, West-Germany || || Internet: muenx@heike.informatik.uni-dortmund.de || =========================================================================== Sample code (sorry for missing documentation): #include <X11/Intrinsic.h> #include <X11/Shell.h> #include <Xm/Xm.h> #include <Xm/BulletinB.h> #include <Xm/Label.h> #include <Xm/MainW.h> #include <Xm/RowColumn.h> #include <Xm/Text.h> Widget MakeRowCol(); Widget MakeText(); void Callback(); Arg Args[10]; int n; main(argc, argv) int argc; char **argv; { Display *Disp; Widget Shell, MainWindow, BB; XtToolkitInitialize(); Disp = XtOpenDisplay(NULL, NULL, argv[0], "XUADM", NULL, 0, &argc, argv); Shell = XtAppCreateShell(argv[0], "XUADM", applicationShellWidgetClass, Disp, NULL, 0); n = 0; MainWindow = XmCreateMainWindow(Shell, "main", Args, n); XtManageChild(MainWindow); MakeText(MainWindow, "Test #1:", Callback); n = 0; XtSetArg(Args[n], XmNdialogTitle, XmStringCreateLtoR("Window", XmSTRING_DEFAULT_CHARSET)); n++; BB = XmCreateBulletinBoardDialog(MainWindow, "Window", Args, n); MakeText(BB, "Test #2:", Callback); XtManageChild(BB); XtRealizeWidget(Shell); XtMainLoop(); } void Callback(w, client_data, call_data) Widget w; caddr_t client_data; caddr_t call_data; { printf("Entered: %s\n", XmTextGetString(w)); } Widget MakeRowCol(Parent, Orientation) Widget Parent; unsigned char Orientation; { Widget RowCol; n = 0; XtSetArg(Args[n], XmNorientation, Orientation); n++; RowCol = XmCreateRowColumn(Parent, "RowCol", Args, n); XtManageChild(RowCol); return RowCol; } Widget MakeText(Parent, Question, Callback) Widget Parent; char *Question; void (*Callback)(); { Widget RowCol, Label, Text; RowCol = MakeRowCol(Parent, XmHORIZONTAL); n = 0; Label = XmCreateLabel(RowCol, Question, Args, n); XtManageChild(Label); n = 0; XtSetArg(Args[n], XmNcolumns, 8); n++; XtSetArg(Args[n], XmNmaxLength, 8); n++; Text = XmCreateText(RowCol, "Text", Args, n); XtAddCallback(Text, XmNactivateCallback, Callback, NULL); XtManageChild(Text); return Text; }
nazgul@alphalpha.com (Kee Hinckley) (07/04/90)
In article <2280@laura.UUCP> muenx@heike.informatik.uni-dortmund.de (Holger Muenx) writes: > Text-Widgets. If I press the <Return> key in one widget the next text > widget should automatically be activated so that the user can continue Using TabGroups will make the Tab key do this, it should be straightforward to add a translation so that the Return key does as well. I don't know why this isn't the default, except that in dialog boxes return is mapped to clicking on the default button. >2. I have written an application which uses different windows. I create a > new window using the XmBulletinBoard-class. Text-Widgets in my main-window > call their callback without any problem. Text-Widget in BulletinBoards > refuse to call their callback. What's my mistake? See the sample code > below my signature. It created two text-widgets, one in the main-window > and one in the new BulletinBoard. As above, return is mapped to invoking the default button in a dialog box, I wouldn't be supprised if the bulletin board (which doubles as the thing that handles dialog box translations) is getting in the way here. You may be able to override, but I think that using activate in a text widget is dangerous. What if the user types something but doesn't press return. As far as they can tell it is there, but you haven't seen it. I'd tend to instead have a confirm button somewhere which gathers up the contents of you text widgets. -- Alphalpha Software, Inc. | motif-request@alphalpha.com nazgul@alphalpha.com |----------------------------------- 617/646-7703 (voice/fax) | Proline BBS: 617/641-3722 I'm not sure which upsets me more; that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's.