Technical article 100849

Compose or dead key sequences don't work when used in Motif text widgets.

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

Problem

Using a compose or dead key sequence in a Motif text widget to display an 8-bit character does not work; only 7-bit characters are echoed.

Solution

Compose and dead keys can be used in XmText(Xm) widgets if the following conditions are true:

1. XtSetLanguageProc(Xt) is called at the start of your program (it is the Xt equivalent of setlocale(S)).

2. The LANG environment variable specifies an 8859 codeset. For example, "french_france.8859".

3. The text widget uses an iso8859 font (use xlsfonts(XC) to list the fonts available to your X-server).

The following is an example of how to do this using the XmTextField(Xm) widget:

xmtext.c:
-------------------------------------------------------------------------------
#include <Xm/TextF.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xm/MainW.h>
void main(argc, argv)
unsigned int    argc;
char            **argv;
{
   Widget       toplevel, form, text, mainwin, frame;
   XtAppContext app_context;
   int          i;
   Arg          myArgs[10];
XtSetLanguageProc(NULL, NULL, NULL);

toplevel = XtAppInitialize(&app_context, "xmtext", NULL, 0, &argc, argv, NULL , NULL, 0);

mainwin =  XmCreateMainWindow(toplevel, "mainwin", NULL, 0);
XtManageChild(mainwin);
frame = XmCreateFrame(mainwin, "frame", NULL, 0);
XtManageChild(frame);
form = XmCreateForm(frame, "form", NULL, 0);
XtManageChild(form);

i = 0; XtSetArg(myArgs[i], XmNeditable, TRUE); i++; XtSetArg(myArgs[i], XmNtopAttachment, XmATTACH_FORM); i++; XtSetArg(myArgs[i], XmNleftAttachment, XmATTACH_FORM); i++; XtSetArg(myArgs[i], XmNcolumns, 20); i++; text = XmCreateTextField(form, "text", NULL, 0); XtManageChild(text);

XmMainWindowSetAreas(mainwin, NULL, NULL, NULL, NULL, frame);
XtRealizeWidget(toplevel);
   XtAppMainLoop(app_context);
}
Makefile:
-------------------------------------------------------------------------------
CFLAGS = -g -belf -DSYSV
INCLUDES =
LIBRARIES = -lXm -lXt -lX11 -lsocket -lnsl_s
xmtext: xmtext.o
         cc $(CFLAGS) $(INCLUDES) -o xmtext xmtext.o $(LIBRARIES)
xmtext.o:
         cc $(CFLAGS) $(INCLUDES) -c xmtext.c
Defaults file, or entry in $HOME/.Xdefaults:
-------------------------------------------------------------------------------
xmtext*fontList:        9x15

See also

XtLanguageProc(Xt), XmText(Xm), XmTextField(Xm), setlocale(S),
locale(M)

From the Xinuos technical article database, record 100849. Reproduced with permission. The original is at www.sco.com/ta/100849, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.