Morph dragging code?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Morph dragging code?

timrowledge
I’m trying to assemble a decent understanding of how the Morphic drag & drop works in order to write a reasonable tutorial and other doc for the swiki. I haven’t found anything notably helpful in the image and obviously not on the swiki or I wouldn’t be needing to write this... for the swiki.

My hope is to use a version of the old Plumbin’ example as a hook to hang things upon; I want to make a morph to act as the source of tiles, another as the playing field and of course the tiles. As previously mentioned ,there are a couple of versions of gamified Plumbin’ around but they don’t seem to me to be good vehicles for a tutorial. I want to keep it as simple as plausible and to make sure it is understandable without needing too many other aspects of the system in the reader’s head. Or mine, for that matter!

Marcel helped me start off down the drop related trail a few weeks ago with a superb quick overview that has been very helpful. I have a nice couple of initial examples for dealing with dropping that don’t need any coding at all, which is nice as a starting point.

Unfortunately the drag related stuff seems a lot less organised. I see the #dragEnable & similar methods, the #startDrag: stuff and the rather inelegant PasteUpMorph>mouseDown: code but nothing seems to hang together to make a clean story yet. What am I missing? Is there any documentation that I simply haven’t stumbled across? A really good example already out there?

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Bad command or file name.  Go stand in the corner.



Reply | Threaded
Open this post in threaded view
|

Re: Morph dragging code?

marcel.taeumel (old)
Hi, Tim!

Maybe you are missing #waitForClicksOrDrag:event:selectors:threshold: in HandMorph, which can be used to register some callbacks for click, double-click, and drag-start. The default callbacks are listed in #waitForClicksOrDrag:event:.

I encapsulated a lot of event handling stuff in the class UiEventHandler, which can be found in my Widgets project, to make use of my signals. There, you see that I use #mouseDown: to register those callbacks (i.e. #mouseDown:fromMorph in UiEventHandler), too. Just like the default Morphic event handler, called EventHandler.

Maybe you could explain the whole thing by using an event handler object for morphs. By default, there is no such event handler and programmers are requested to overwrite #mouseDown: etc. in subclasses.

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: Morph dragging code?

marcel.taeumel (old)
P.S.: There is an #on:send:to: in the default Morphic EventHandler class. :)
Reply | Threaded
Open this post in threaded view
|

Re: Morph dragging code?

Karl Ramberg
Most use of picking up a morph is in PasteUpMorph>>mouseDown:

Easiest way to do drag and drop is to use a PasteUpMorph as a play field and use the already implemented drag and drop functionality. 


Cheers,
Karl


On Sat, Jan 4, 2014 at 2:23 PM, Marcel Taeumel <[hidden email]> wrote:
P.S.: There is an #on:send:to: in the default Morphic EventHandler class. :)



--
View this message in context: http://forum.world.st/Morph-dragging-code-tp4734010p4734104.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.




Reply | Threaded
Open this post in threaded view
|

Re: Morph dragging code?

Chris Muller-3
In reply to this post by timrowledge
There are several examples in the image, did you look at references to
TransferMorph?

Maui uses drag-and-drop extensively, you can load it from SqueakMap.

IIRC, it follows the same pattern as the other event-handling methods
of Morphic.  There is one that returns a boolean establishing
permission to respond to that event (e.g., #handlesMouseOverDragging
and #handlesMouseEnterDragging) and, if true, calls the corresponding
handler method(s) (#mouseEnterDragging, #mouseLeaveDragging).

On Fri, Jan 3, 2014 at 5:41 PM, tim Rowledge <[hidden email]> wrote:

> I’m trying to assemble a decent understanding of how the Morphic drag & drop works in order to write a reasonable tutorial and other doc for the swiki. I haven’t found anything notably helpful in the image and obviously not on the swiki or I wouldn’t be needing to write this... for the swiki.
>
> My hope is to use a version of the old Plumbin’ example as a hook to hang things upon; I want to make a morph to act as the source of tiles, another as the playing field and of course the tiles. As previously mentioned ,there are a couple of versions of gamified Plumbin’ around but they don’t seem to me to be good vehicles for a tutorial. I want to keep it as simple as plausible and to make sure it is understandable without needing too many other aspects of the system in the reader’s head. Or mine, for that matter!
>
> Marcel helped me start off down the drop related trail a few weeks ago with a superb quick overview that has been very helpful. I have a nice couple of initial examples for dealing with dropping that don’t need any coding at all, which is nice as a starting point.
>
> Unfortunately the drag related stuff seems a lot less organised. I see the #dragEnable & similar methods, the #startDrag: stuff and the rather inelegant PasteUpMorph>mouseDown: code but nothing seems to hang together to make a clean story yet. What am I missing? Is there any documentation that I simply haven’t stumbled across? A really good example already out there?
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> Bad command or file name.  Go stand in the corner.
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Morph dragging code?

timrowledge
In reply to this post by Karl Ramberg

On 05-01-2014, at 1:05 PM, karl ramberg <[hidden email]> wrote:

> Most use of picking up a morph is in PasteUpMorph>>mouseDown:

Yah, I eventually found that. Definitely a serious lack of documentation here.

So far I’ve found the
over-ride #mouseDown: and
add an event handler for #startDrag
approaches


>
> Easiest way to do drag and drop is to use a PasteUpMorph as a play field and use the already implemented drag and drop functionality.

The problem with that - and the PasteUpMorph subclass ‘PartsBin’ is that they are huge, heavy, complex classes with a lot of function completely irrelevant to what I want - and horribly not what I want to explain in a tutorial!

On 05-01-2014, at 2:40 PM, Chris Muller <[hidden email]> wrote:

> There are several examples in the image, did you look at references to
> TransferMorph?

I saw TransferMorph; that’s an interesting oddity since they aren’t there until *some other* morph has created one as part of *its* drag handling. That changes what parts of the protocol are needed.

>
> Maui uses drag-and-drop extensively, you can load it from SqueakMap.

I knew that somewhere in the attic that is called my memory, but didn’t think of it as a source for examples. I’ll take another look.

It’s an interesting problem. Dragging is quite a bit more involved than the drop at the end, at least from the point of view of trying to explain it simply and provide small examples to illustrate.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Oxymorons: Political science



Reply | Threaded
Open this post in threaded view
|

Re: Morph dragging code?

timrowledge
In reply to this post by Chris Muller-3
After digging around a large number of drag/drop related methods I have
a) a rather better understanding of how it works
b) a small list of rather odd methods that seem in need of a moments consideration and probably improving.

I’ll Mantisificate the full list, but the basic story is that there seems to be some confusion about the meaning and use of #isPartsBin[:] & #isPartsDonor[:], a rather confused PasteUpMorph>repelsMorph:event: (and #wantsDroppedMorph:event:), and the usual confused and/or outdated comments that mislead the reader.

A swiki tutorial should appear fairly soon, including a Plumbin’ example.

See http://bugs.squeak.org/view.php?id=7807

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: QVC: Question Valid Command



Reply | Threaded
Open this post in threaded view
|

Re: Morph dragging code?

Karl Ramberg
Hi

A few comments:
CompoundTileMorph contain other morphs that wants drops, so I don't think you can reject drops to it.

Morph>>mouseDownPriority shows some of the confusion with isPartsBin and isPartsDonor

Cheers,
Karl


On Wed, Jan 8, 2014 at 7:29 PM, tim Rowledge <[hidden email]> wrote:
After digging around a large number of drag/drop related methods I have
a) a rather better understanding of how it works
b) a small list of rather odd methods that seem in need of a moments consideration and probably improving.

I’ll Mantisificate the full list, but the basic story is that there seems to be some confusion about the meaning and use of #isPartsBin[:] & #isPartsDonor[:], a rather confused PasteUpMorph>repelsMorph:event: (and #wantsDroppedMorph:event:), and the usual confused and/or outdated comments that mislead the reader.

A swiki tutorial should appear fairly soon, including a Plumbin’ example.

See http://bugs.squeak.org/view.php?id=7807
Strange OpCodes: QVC: Question Valid Command






Reply | Threaded
Open this post in threaded view
|

Plumbin' At Last (was Re: [squeak-dev] Morph dragging code?)

timrowledge
In reply to this post by timrowledge
I finally got my Plumbin’ working. It goes with a tutorial on using Drag & Drop in Morphic. See http://bugs.squeak.org/view.php?id=7807 for the tutorial and http://wiki.squeak.org/squeak/701 for Plumbin’ - including the code.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Ubi dubium ibi libertas


Reply | Threaded
Open this post in threaded view
|

Re: Plumbin' At Last (was Re: [squeak-dev] Morph dragging code?)

Karl Ramberg
Hi,
DragSourceMorph is missing from the change set.

Cheers,
Karl


On Sun, Jan 12, 2014 at 2:19 AM, tim Rowledge <[hidden email]> wrote:
I finally got my Plumbin’ working. It goes with a tutorial on using Drag & Drop in Morphic. See http://bugs.squeak.org/view.php?id=7807 for the tutorial and http://wiki.squeak.org/squeak/701 for Plumbin’ - including the code.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Ubi dubium ibi libertas





Reply | Threaded
Open this post in threaded view
|

Re: Plumbin' At Last (was Re: [squeak-dev] Morph dragging code?)

timrowledge

On 12-01-2014, at 2:38 AM, karl ramberg <[hidden email]> wrote:

> Hi,
> DragSourceMorph is missing from the change set.

Well spotted. FIxed.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful Latin Phrases:- Anulos qui animum ostendunt omnes gestemus! = Let's all wear mood rings!



Reply | Threaded
Open this post in threaded view
|

Re: Plumbin' At Last (was Re: [squeak-dev] Morph dragging code?)

Karl Ramberg
Works now

Cheers,
Karl


On Sun, Jan 12, 2014 at 7:36 PM, tim Rowledge <[hidden email]> wrote:

On 12-01-2014, at 2:38 AM, karl ramberg <[hidden email]> wrote:

> Hi,
> DragSourceMorph is missing from the change set.

Well spotted. FIxed.
Useful Latin Phrases:- Anulos qui animum ostendunt omnes gestemus! = Let's all wear mood rings!






Reply | Threaded
Open this post in threaded view
|

Re: Plumbin' At Last (was Re: [squeak-dev] Morph dragging code?)

Chris Muller-3
In reply to this post by timrowledge
Thanks for respecting the release.  4.6 will be off to a good start.

On Sat, Jan 11, 2014 at 7:19 PM, tim Rowledge <[hidden email]> wrote:
> I finally got my Plumbin’ working. It goes with a tutorial on using Drag & Drop in Morphic. See http://bugs.squeak.org/view.php?id=7807 for the tutorial and http://wiki.squeak.org/squeak/701 for Plumbin’ - including the code.
>
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> Ubi dubium ibi libertas
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Plumbin' At Last (was Re: [squeak-dev] Morph dragging code?)

timrowledge
Damn. Somehow I pasted in completely the wrong URL. Should be
http://wiki.squeak.org/squeak/6194
for the drag & drop tutorial.

I’ve just edited in a couple more methods involved in dropping & added quick reference lists of the important messages.

On 13-01-2014, at 1:50 PM, Chris Muller <[hidden email]> wrote:

> Thanks for respecting the release.  4.6 will be off to a good start.
>
> On Sat, Jan 11, 2014 at 7:19 PM, tim Rowledge <[hidden email]> wrote:
>> I finally got my Plumbin’ working. It goes with a tutorial on using Drag & Drop in Morphic. See http://bugs.squeak.org/view.php?id=7807 for the tutorial and http://wiki.squeak.org/squeak/701 for Plumbin’ - including the code.
>>


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful random insult:- Always responds to "Make Money Fast" postings on the Net.