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_sxmtext: xmtext.o
cc $(CFLAGS) $(INCLUDES) -o xmtext xmtext.o $(LIBRARIES)xmtext.o:
cc $(CFLAGS) $(INCLUDES) -c xmtext.cDefaults file, or entry in $HOME/.Xdefaults:
-------------------------------------------------------------------------------
xmtext*fontList: 9x15 See also
XtLanguageProc(Xt), XmText(Xm), XmTextField(Xm), setlocale(S),
locale(M)