Hello,
I am new in motif and need your help very much.
I must write new widget which will be extension of XmText widget (need to add some actions and functionality).
I think there must be some way to do it and I don`t need to write new widget from zero as subclass of Primitive widget.
Could you please tell me how to do it or send me some documentation or if you have example code of new widget.
Thanks in advance,
hsn.bob
P.S.
I have read Motif 2.1 - Widget Writer`s Guide, but it just show how to write subclass of Primitive or Manager widget.
Subclassing XmText is not for the faint hearted, especially if you have never written widgets before.
You can probably accomplish what you want to do by just creating an XmText widget, then either add an event handler to it, or modify its translation table using XtOverrideTranslations() or XtAugmentTranslations().
fredk thanks for response.
I have done it already, added necessary functionality by setting event handler and adding/overriding translations/actions,
and now have XmText widget with necessary functionality.
But problem is in following. In my application there will be more than one such widget, so not to add the same functionality
for every XmText widget I decided to write new one (subclass of XmText with necessary functionality) and to use that one everywhere.
I would ask you to suggest some documentation or give some advise what to do.
Or if you have any other ideas how to solve my problem please write.
Thanks in advance,
hsn.bob
Subclassing XmText is not easy.
You can probably accomplish what you want by setting an EVentHandler and/or adding/overriding translations/actions on the widget.
fredk thanks for response.
I have done it already, added necessary functionality by setting event handler and adding/overriding translations/actions,
and now have XmText widget with necessary functionality.
But problem is in following. In my application there will be more than one such widget, so not to add the same functionality
for every XmText widget I decided to write new one (subclass of XmText with necessary functionality) and to use that one everywhere.
I would ask you to suggest some documentation or give some advise what to do.
Or if you have any other ideas how to solve my problem please write.
Thanks in advance,
hsn.bob
Just write a wrapper function that creates this type of text.
Widget createModifiedXmText( Widget parent, String name, Arg args[], int numArgs,
XtEventHandler proc, XtPointer data ) {
EventMask mask = ...;
Boolean unmaskable = ...;
Widget w = XmCreateText( parent, name, args, numArgs );
XtAddEventHandler( w, mask, unmaskable, proc, data );
XtOverrideTranslations( w, translations );
return w;
}
You might also consider posting your questions to newsgroup comp.windows.x.motif
It is not extremely active, but is unmoderated so your posts show up reasonably quickly.
Thanks fredk for your advises and for newsgroup.
What I understand is that it is very difficult to find active resource for motif.
After a week I will start implementing this and will try what you suggest.
One more time thank you very much , I will write about results.
hsn.bob
Thank you fredk for your help very much.
Your advises help me to solve my problem.
hsn.bob