[comp.windows.x] Drag and drop w/MOTIF

san@halley.UUCP (Steve Sanderson) (08/03/90)

Has anyone done drop (& drag) of widgets (or anything...) under MOTIF?

Specifically, I'd like to have objects on screen which I can select w/a
mouse button, drag it around & possibly drop it somewhere, w/the object
underneath being notified.

I've tried using a drawing area w/diff. widgets (label, pushbutton):
I used the translation table/actions to work off of a Button1MotionNotify
event; but they aren't propagated up to the drawing area when I button1
a widget - even though they don't appear to be using that event

 - is there anyway to make a widget insensitive *AND* propagate it's events
   up to the parent?

 - has anyone done something like this?

Thanks,

Steve Sanderson
halley!san@cs.utexas.edu

olson@sax.cs.uiuc.edu (Robert Olson) (08/03/90)

In article <935@halley.UUCP> san@halley.UUCP (Steve Sanderson) writes:
>Has anyone done drop (& drag) of widgets (or anything...) under MOTIF?

<< I tried to send you email, but it bounced...>>

I've done it.

The application I am doing has a palette of icons that I want to drag
over into a workspace, where I can arrange them and connect them up.

The hierarchy of widgets is

			BulletinBoard (backingWindow)
			       	 |
			         |
			         |
	        	Form (mainWindow)
                           |             \
			   |		  \
			   |		   \
		      RowColumn (palette)   DrawingArea (workWindow)
                       	   |
		       	   |
		       	   |
		      Label (palette items)

Each palette item has a ButtonPress event handler. When the button is
pressed on a label widget, a copy of the widget is created, with the
backingWindow as the parent. This widget has ButtonMotion and
ButtonRelease event handlers. As it receives motion events, it is
moved in the window to correspond to the mouse position. When it
receives a release event, it checks to see if the mouse pointer is in
the workWindow. If it is, another copy of the widget is created, this
time with the workWindow as a parent, and placed in the proper
location in the workWindow.

Similarly, the widgets in the workWindow have ButtonPress,
ButtonMotion, and ButtonRelease event handlers. These work similarly
to what I've described above, with the exception that no copying is
needed since all that is happening is the widget is sliding around in
the workWindow. 

The reason I make the moving widget a child of the BulletinBoard is
that the Form constrains the positions of the child, and so the child
cannot move freely in it.

Let me know if you have any questions

--bob
--
Bob Olson			University of Illinois at Urbana/Champaign
Internet: rolson@uiuc.edu	UUCP:  {uunet|convex|pur-ee}!uiucdcs!olson
"You can't win a game of chess with an action figure!" AMA #522687 DoD #28
<<Dee's address: dee%fazer.uucp@harp.cs.uiuc.edu>>