malbert@jeeves.shearson.com (Marc Albert) (04/25/91)
Following is a small program. It attempts to get the contents of
CUT_BUFFER0 via the selection mechansism (sp?) whenever a Btn2Down
event happens. I can't seem to make it work - in the function
SelectCallback *type always == 0 (XT_CONVERT_FAIL) and *length
always == 0.
Any suggestions would be appreciated.
#include <stdio.h>
#include <string.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xatom.h>
#include <X11/Xaw/AsciiText.h>
static Widget topLevel;
void SelectionCallback(widget, ClientData, selection, type, value, length, format)
Widget widget;
XtPointer ClientData;
Atom *selection, *type;
XtPointer value;
unsigned long *length;
int *format;
{
char *ptr;
ptr = (char *)value;
printf("Type: %d, Length: %d, Value: %s\n", *type,
*length, ptr);
fflush(stdout);
}
void HandleNewRequest()
{
Widget widget;
widget = XtNameToWidget(topLevel, "*text");
XtGetSelectionValue(widget, XA_CUT_BUFFER0, XA_STRING,
SelectionCallback, (XtPointer)0,
XtLastTimestampProcessed(XtDisplay(widget)));
}
Widget CreateHelpScreen(parent)
Widget parent;
{
Widget widget;
widget = XtCreateManagedWidget("text", asciiTextWidgetClass,
parent, (Arg *)0, (Cardinal)0);
return(widget);
}
void main(argc, argv)
int argc;
char **argv;
{
Widget text;
static XtActionsRec actions[] = {
{ "Button2Press", HandleNewRequest }
};
topLevel = XtInitialize("xhelp", "XHelp", NULL, 0, &argc, argv);
text = CreateHelpScreen(topLevel);
XtAddActions(actions, XtNumber(actions));
XtRealizeWidget(topLevel);
XtOverrideTranslations(text,
XtParseTranslationTable("<Btn2Down>: Button2Press()"));
XtMainLoop();
}
--
Marc.
=====================================================================
Marc Albert Lehman Brothers
US Mail 388 Greenwhich Street, New York, NY
UUCP ...uunet!shearson.com!malbert
Work Phone (212) 464-3061
Home Phone (203) 378-8232malbert@jeeves.shearson.com (Marc Albert) (04/26/91)
I have a small program which simply contains an Athena text widget. When this program tries to do an XtGetSelectionValue() the message Error: Couldn't find per display information. is displayed. When this program is converted to OLIT everything is fine. Anyone have any clues? -- Marc. ===================================================================== Marc Albert Lehman Brothers US Mail 388 Greenwhich Street, New York, NY UUCP ...uunet!shearson.com!malbert Work Phone (212) 464-3061 Home Phone (203) 378-8232