Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!ucsdhub!sdcsvax!ucsd!rutgers!gatech!bloom-beacon!ATHENA.MIT.EDU!kit From: kit@ATHENA.MIT.EDU (Chris D. Peterson) Newsgroups: comp.windows.x Subject: Re: Text Widget Question Message-ID: <8812231734.AA05361@DORA.MIT.EDU> Date: 23 Dec 88 17:34:48 GMT References: <8812222359.AA01387@thelake.cray.com> Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 63 Using Argument Lists: IMPORTANT - toolkit programmers please read. Understanding how argument lists work is fundamental to X toolkit programming, an you must understand them of you are going to have any success with the X toolkit. Agrument lists consist of name-value pairs, and while the names are well defined and easy enough to come up with, people have trouble with the values, so let me state it once again, in the hope that I do not need to repeat it again 10 times over the next year. Values passed into a widget through its argument list or set via XtSetValues(), are not passed through a string converter, this means that you have to specify the actual value of the item that the widget is expecting for this resource. Integers must be passed as integers ( 3 not "3" ), Pixel values must be passed as pixel values ( Pixel that corrosponds to black not the string "black"). Just to keep things from being dull, if the size of the item that you are passing is larger than (XtArgVal) then you must pass the item by reference (read: pass its pointer), Otherwise just pass its value. A word of caution: When using XtGetValues() the argument lists it expects are name "address" pairs, rather than name-value pairs. Some Examples: Right: XtSetArg(arglist[num_args], XtNwidth, 45); num_args++; Wrong: XtSetArg(arglist[num_args], XtNwidth, "45"); num_args++; Right: XtSetArg(arglist[num_args], XtNcolor, BlackPixel(display, scr_num)); num_args++; Wrong: XtSetArg(arglist[num_args], XtNcolor, "black"); num_args++; On to the Specific question at hand: > Question: Given the following text translation table and arguments > to an AsciiStringWidget, why do I get the *default* Text translation > table? [ Table deleted. ] > static Arg roll_arg[] = {{XtNheight,(XtArgVal)50}, > . > . > . > {XtNtranslations, (XtArgVal) roll_translations}, > > roll_box=XtCreateManagedWidget("roll_input",asciiStringWidgetClass, > box,roll_arg,XtNumber(roll_arg)); roll_box=XtCreateManagedWidget("roll_input",asciiStringWidgetClass, box, NULL, 0); XtOverrideTranslations(roll_box, XtParseTranslations(roll_translations)); This will leave all the current translations in the text widget, and override only those that you have specified with new values. The X11R3 Client "xman" does some overriding of translations if you would like to look at a real example. If you really want to specify an entirely new translation table then have your argument list look like this: XtSetArg(arglist[num_args], XtNtranslations, XtParseTranslationTable(roll_translations));