[comp.windows.x] Translations and MaximumLength with Xaw's dialogWidgetClass

tdm@allspice.lcs.mit.edu (Trevor Mendez) (04/24/91)

Hello,
     I'm having no success trying to get an Xaw dialog box widget to 
ignore characters like CR by changing the translations.  My program core
dumps later because of problems that occur when the CR's are typed.  Doing
this also pushes buttons in the shell widget out of sight.  I'm also
unable to have the widget refuse to accept any characters once a max.
number of input has been entered.  Help.  Here's the related function:

void
DoAddName(x, y)
  int x, y;
{
  Arg args[10];
  int nargs;
  XtTranslations trans_table;
  Position abs_x, abs_y;
  Window junk_window;
  static char defaultTranslations[] =
        "#override\n<Key>Return:        beep()";

  if (edit_operation != ADD || edit_suboperation != PLACE)
    return;
  edit_suboperation = ADDNAME;
  nodex = x; nodey = y;

  trans_table = XtParseTranslationTable(defaultTranslations);

  XtTranslateCoords(network, (Position) x, (Position) y, &abs_x, &abs_y);

  nargs = 0;
  XtSetArg(args[nargs], XtNx, abs_x); nargs++;
  XtSetArg(args[nargs], XtNy, abs_y); nargs++;
  XtSetArg(args[nargs], XtNinput, (XtArgVal)TRUE); nargs++;
  dialogshell = XtCreatePopupShell("dialogshell", transientShellWidgetClass,
        network, args, nargs);

  nargs = 0;
  XtSetArg(args[nargs], XtNlabel, "Enter node name & choose type"); nargs++;
  XtSetArg(args[nargs], XtNvalue, "node"); nargs++;
  XtSetArg(args[nargs], XtNtranslations, trans_table); nargs++;
  XtSetArg(args[nargs], XtNmaximumLength, 5); nargs++;
/* tdm
  XtSetArg(args[nargs], XtNmaximumLength, MAX_NODE_CHARS-1); nargs++;
*/
  XtSetArg(args[nargs], XtNx, x); nargs++;
  XtSetArg(args[nargs], XtNy, y); nargs++;
  XtSetArg(args[nargs], XtNnodex, x); nargs++;
  XtSetArg(args[nargs], XtNnodey, y); nargs++;
  nodename = XtCreateManagedWidget("nodename", dialogWidgetClass,
        dialogshell, args, nargs);

  XawDialogAddButton(nodename, " Node ", DoAddNet, (caddr_t) 1);
  XawDialogAddButton(nodename, " Ether", DoAddEther, (caddr_t) 2);
  XawDialogAddButton(nodename, "Cancel", DoCancel, (caddr_t) dialogshell);
  XtRealizeWidget(dialogshell);
  RepositionWidget(network, dialogshell);
  XtPopup(dialogshell, XtGrabNone);
}

Thanx.
Trevor Mendez	tdm@allspice.lcs.mit.edu