Drag and Drop Btn1 in C++ and motif

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

3 posts / 0 new
Last post
Drag and Drop Btn1 in C++ and motif

Submitted by vegettovk on Mon, 01/26/2009 - 12:17.

Hi.

I'm programming in C++ with motif and I have to develope copy-paste by drag and drop with the left button of the mouse (btn1). The main idea is to select text with the left button and drag and drop the selection in a text_field with the left button again.

¿Does anyone know how do this?
Thanks.

Tue, 01/27/2009 - 15:43#1

Tue, 01/27/2009 - 15:43#1

vtorshyn

Re: Drag and Drop Btn1 in C++ and motif

Hi vegettovk,
It is possible to override Drag and Drop behavior by replacing default translations.
XmTextField widget has Button1 binding to start drag, and action called 'process-bdrag', you might want replace it by translations (see TextF.c code):
...
static char myTranslation[] = ": process-bdrag()";
...
Then register such translation by a XtOverrideTranslations().
But, in this case such actions like Enter() might work not correctly (because default button which do enter/focusIn action is replaced). So if you want select the widget you should use middle button.

In case when required more flexibility you should write your own action.
...
static char myTranslation[] = ": myDragAction()";
static XtActionsRec myActions[] = {
{"myDragAction", myStartDrag }
};
static void myStartDrag(Widget w,XEvent * event, String * params, Cardinal * num_params)
{
/*Here you should write your own code for drag operation*/
...
/*Finaly, call XmTextField drag */
ProcessBDrag(w, event, params, num_params);
}
...

Also some useful examples you can find in Motif Programming Manual, volume Six A.

Mon, 02/02/2009 - 07:59#2

Mon, 02/02/2009 - 07:59#2

vegettovk

Re: Drag and Drop Btn1 in C++ and motif

Thank You very much for replaying my post.

I can see that with this source I could capture the mouse event and develope the drag action but, How can I do the copy action in this source?

I'm a beginner with Motif and I don't know developer many things in this language.
Thank you again.