I've been struggling with a Motif/X problem for a few days now. A big
problem is that this is my first look under the hood at the Motif
translation/action mechanism and it's relationship with Xt.
Anyway, the problem is that my Motify translations for an
XmDrawingArea widget do not result in a callback and I can't
understand why. I'm adding these translations to an existing
application.
The resource file:
WIN_176*DrawingArea.translations : #override \n\
<EnterNotify>: enterMessage()\n\
<LeaveNotify>: exitMessage()
Where DrawingArea is the XmDrawingArea, a grandchild (maybe great
great) of window 176.
What I would really like to do is somehow interrogate the widget and
see if these translation have made it into the widget's translation
table; or know why it's being ignored. How can I debug this?
Any help or hints greatly appreciated.
Thanks,
Jevon
I added the translations in the code: i.e
/* START HACK */
if (strcmp((widget->core.name), "DrawingArea") == 0)
{
XtTranslations translations;
static String string =
"<EnterNotify>:enterMessage\n\
<LeaveNotify>:exitMessage")";
translations = XtParseTranslationTable(string);
XtOverrideTranslations(widget, translations);
}
/* END HACK */
And this works. What could be wrong with my resource file?
Thanks,
Jevon
How could this even compile? the core part of a widget
does not have a field called "name". You should be using
XtName(widget)
> {
> XtTranslations translations;
> static String string =
> "<EnterNotify>:enterMessage\n\
> <LeaveNotify>:exitMessage")";
Again, this can't compile - there's an extra quote (")
Also, this is incorrect syntax for translations since it is missing
the
parentheses :
"<EnterNotify>:enterMessage()\n\
<LeaveNotify>:exitMessage()";
>
> translations = XtParseTranslationTable(string);
> XtOverrideTranslations(widget, translations);
> }
> /* END HACK */
>
> And this works. What could be wrong with my resource file?
>
Are you sure you want to override the enter and leave translations
completely>
You should add your items, but leave the existing ones so
the drawing area works properly. To have your functions
called before the normal functions, use
"<EnterNotify>:enterMessage() ManagerEnter()\n\
<LeaveNotify>:exitMessage() ManagerLeave()";
that should allow the drawing area to handle its children properly
while still calling your functions.One also presumes you added
an action table so the toolkit knows what functions to
associate with the strings "enterMessage" and "exitMessage".
In your original post, you said you tried
> WIN_176*DrawingArea.translations : #override \n\
> <EnterNotify>: enterMessage()\n\
> <LeaveNotify>: exitMessage()
>
>
> Where DrawingArea is the XmDrawingArea, a grandchild (maybe great
> great) of window 176.
I do not understand "window 176".
This might work if your application name, as passed to
XtAppInitialize as the application_class, is "WIN_176".
You might try:
?*WIN_176*DrawingArea.translations
--
Fred Kleinschmdit
> How could this even compile?
...
> Again, this can't compile - there's an extra quote (")
...
> Also, this is incorrect syntax for translations since it is missing
> the parentheses :
Yes, you are right - that code above wouldn't compile. I had to
manipulate
the original code in this post so it would be readable. But the
intention of
the code is the same. I think you have understood correctly.
Fred, thanks for your help. What you have said makes sense.
Thanks,
Jevon