How do I get the code that does the first part of drag and drop to kick in? Here's a tentative answer; I welcome corrections.
I have two morphs. I want to click on the inner morph and, if I keep the mouse down, drag it out. I seem to be having problems getting the click-drag hooked into the start of the drag code.
After experimenting, it seems the key is to capture the mouseDown event (via #handlesMouseDown:) and then mouseDown: evt ^self grabMorph: evt
Should I be using grabTransform in here? Is this the right idea? (I was inspired by browsing senders of #grabMorph:).
My outer morph (Morph subclass: MorphA) is initialized with initialize |b| super initialize. self color: self defaultColor. self extent: 100@100; enableDragNDrop. b _ MorphB new. b center: self center; extent: self extent / 3.0. self addMorphFront: b.
On the one hand, I thought that drag and drop was supposed to work pretty automatically. On the other, I don't see how it could: if I click on a morph I may want to popup a menu, perform some action, or drag it, and it seems that needs to be in the code.
If I get past this to a real world example, I'll also have several levels of nesting. For example if D is in C in B in A, and I want to be able to drag D out (really a copy of it), which of A, B, and C need changes to support it? I was going to research this on my own, when I discovered I couldn't even handle the B in A case :(.
P.S. As others have noted David Smith's stuff on the swiki doesn't conform to current protocols. I'm running 3.1 alpha #4173.
On Friday 03 August 2001 01:17 am, you wrote:
How do I get the code that does the first part of drag and drop to kick in? Here's a tentative answer; I welcome corrections.
I have two morphs. I want to click on the inner morph and, if I keep the mouse down, drag it out. I seem to be having problems getting the click-drag hooked into the start of the drag code.
Are you using waitForClicksOrDrag: (look at PluggableListMorph>>mouseDown:)
The parent should do the initiation of the drag. So it should use
evt hand grabMorph: submorph. evt hand releaseMouseFocus: self.
On the one hand, I thought that drag and drop was supposed to work pretty automatically. On the other, I don't see how it could: if I click on a morph I may want to popup a menu, perform some action, or drag it, and it seems that needs to be in the code.
enableDragNDrop is for the morph itself. If you ever want to have the drag enabled state different from the drop enabled state, don't use it (use enableDrag: and/or enableDrop:).
Look at PluggableListMorph>>startDrag:
On Fri, Aug 03, 2001 at 09:20:55AM -0700, Ned Konz wrote:
On Friday 03 August 2001 01:17 am, you wrote:
How do I get the code that does the first part of drag and drop to kick in? Here's a tentative answer; I welcome corrections.
I have two morphs. I want to click on the inner morph and, if I keep the mouse down, drag it out. I seem to be having problems getting the click-drag hooked into the start of the drag code.
Are you using waitForClicksOrDrag: (look at PluggableListMorph>>mouseDown:)
No. I'll look into it.
The parent should do the initiation of the drag. So it should use
Why can't the morph initiate the drag itself? And if there is a chain of parents, which one should initiate the drag?
evt hand grabMorph: submorph. evt hand releaseMouseFocus: self.
On the one hand, I thought that drag and drop was supposed to work pretty automatically. On the other, I don't see how it could: if I click on a morph I may want to popup a menu, perform some action, or drag it, and it seems that needs to be in the code.
enableDragNDrop is for the morph itself. If you ever want to have the drag enabled state different from the drop enabled state, don't use it (use enableDrag: and/or enableDrop:).
I'm not sure I understand the meaning of "for the morph itself". The comment on dragEnabled is "Get this morph's ability to add and remove morphs via drag-n-drop." This sounds to me as if to enable me to drag morph B out of containing morph A I must enable dragging in A.
On Friday 03 August 2001 11:46 am, Ross wrote:
On Fri, Aug 03, 2001 at 09:20:55AM -0700, Ned Konz wrote:
The parent should do the initiation of the drag. So it should use
Why can't the morph initiate the drag itself? And if there is a chain of parents, which one should initiate the drag?
Whichever one is handling the mouse event. (i.e. whichever one can tell that a drag operation has started). If you want, you can have a morph get grabbed by the hand; it's just that you don't need enableDrag for this in the parent. You just need someone to tell the hand to grab the morph.
Then you have to deal with the negotiation on the drop, but that's a different problem.
I'm not sure I understand the meaning of "for the morph itself". The comment on dragEnabled is "Get this morph's ability to add and remove morphs via drag-n-drop." This sounds to me as if to enable me to drag morph B out of containing morph A I must enable dragging in A.
That's correct; sorry I wasn't clear.
squeak-dev@lists.squeakfoundation.org