Programmatically simulating drag and drop

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

Programmatically simulating drag and drop

Sean P. DeNigris
Administrator
Does anyone know how to simulate drag and drop?  I managed to pick up a morph via HandMorph attachMorph:, but I can't get the cursor to move (tried position: and a few others).

Thanks.

Sean DeNigris


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically simulating drag and drop

Bert Freudenberg
On 06.04.2010, at 15:48, DeNigris Sean wrote:
Does anyone know how to simulate drag and drop?  I managed to pick up a morph via HandMorph attachMorph:, but I can't get the cursor to move (tried position: and a few others).

Thanks.

Sean DeNigris

How detailed do you need the simulation to be? In the end, dropping results in 

targetMorph addMorph: droppedMorph

- Bert -



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically simulating drag and drop

Sean P. DeNigris
Administrator
Bert Freudenberg wrote
How detailed do you need the simulation to be? In the end, dropping results in

        targetMorph addMorph: droppedMorph
Thanks.  I tried it and it didn't work because what I'm doing is writing an acceptance test, and I need the drag & drop events to fire.  When I do that only, it just adds the "dropped morph" as a sub-morph to the target.

Also, I'm highly curious about how to programmatically interact with the HandMorph in general.  I looked at HandMorphForReplay a little bit, but it seems to use recording of positions (which would be too brittle for a high-level test).

Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically simulating drag and drop

Bert Freudenberg
On 06.04.2010, at 19:02, Sean P. DeNigris wrote:

>
>
> Bert Freudenberg wrote:
>>
>> How detailed do you need the simulation to be? In the end, dropping
>> results in
>>
>> targetMorph addMorph: droppedMorph
>>
>
> Thanks.  I tried it and it didn't work because what I'm doing is writing an
> acceptance test, and I need the drag & drop events to fire.  When I do that
> only, it just adds the "dropped morph" as a sub-morph to the target.

How about this?

        droppedMorph formerPosition: 50@50. "to test rejecting"
        ActiveHand
                position: targetMorph center;
                attachMorph: droppedMorph;
                dropMorphs

>
> Also, I'm highly curious about how to programmatically interact with the
> HandMorph in general.  I looked at HandMorphForReplay a little bit, but it
> seems to use recording of positions (which would be too brittle for a
> high-level test).

Your best bet would be to subclass HandMorph similar to HandMorphForReplay or RemoteHandMorph.

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically simulating drag and drop

Sean P. DeNigris
Administrator
Bert Freudenberg wrote
How about this?

        droppedMorph formerPosition: 50@50. "to test rejecting"
        ActiveHand
                position: targetMorph center;
                attachMorph: droppedMorph;
                dropMorphs
Right on the money!  I was doing the ActiveHand>>position: by itself in a workspace, and the cursor does not get updated, so I thought it wasn't working (need a fresh pair of eyes!).  When I did the drop immediately after, everything worked great.  Thanks again :)

Bert Freudenberg wrote
Your best bet would be to subclass HandMorph similar to HandMorphForReplay or RemoteHandMorph.
Great idea - kind of like living documentation?!

Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically simulating drag and drop

Sean P. DeNigris
Administrator
I did a little more investigating and found a way to get the mouse handlers to work:
        mvevt := MouseMoveEvent new
                setType: #mouseMove
                startPoint: ActiveHand position
                endPoint: 100@100
                trail: nil
                buttons: 0
                hand: ActiveHand
                stamp: TimeStamp current.
               
        ActiveHand handleEvent: mvevt.

        evt := MouseButtonEvent new
                setType: #mouseDown
                position: 50@50
                which: MouseEvent redButton
                buttons: MouseEvent redButton
                hand: ActiveHand
                stamp: TimeStamp current.
       
        ActiveHand handleEvent: evt.

The mouse move is necessary or the grabbed morph flies to wherever the hand is, but even with this, if you touch the mouse after it's grabbed, it flies there anyway.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically simulating drag and drop

Jerome Peace
Hi Sean,

You don't have to use the ACTIVE hand.
Any hand will do.

e.g.

artificialHand = HandMorphForReplay new .

You will have to play and look at the classes. I haven't ever tried this.
So I don't know if this particular solution will work. It should be close.

Worse comes to worse you could base an ArtificialHand class on HandMorphForReplay and make something that worked to your requirements.

Happy hunting.

Yours in curiosity and service, --Jerome Peace





--- On Sat, 5/1/10, Sean P. DeNigris <[hidden email]> wrote:

> From: Sean P. DeNigris <[hidden email]>
> Subject: [Newbies] Re: Programmatically simulating drag and drop
> To: [hidden email]
> Date: Saturday, May 1, 2010, 10:10 PM
>
> I did a little more investigating and found a way to get
> the mouse handlers
> to work:
>     mvevt := MouseMoveEvent new
>         setType: #mouseMove
>         startPoint:
> ActiveHand position
>         endPoint: 100@100
>         trail: nil
>         buttons: 0
>         hand: ActiveHand
>         stamp: TimeStamp
> current.
>        
>     ActiveHand handleEvent: mvevt.
>
>     evt := MouseButtonEvent new
>         setType: #mouseDown
>         position: 50@50
>         which: MouseEvent
> redButton
>         buttons: MouseEvent
> redButton
>         hand: ActiveHand
>         stamp: TimeStamp
> current.
>    
>     ActiveHand handleEvent: evt.
>
> The mouse move is necessary or the grabbed morph flies to
> wherever the hand
> is, but even with this, if you touch the mouse after it's
> grabbed, it flies
> there anyway.
> --
> View this message in context: http://forum.world.st/Programmatically-simulating-drag-and-drop-tp1752837p2122490.html
> Sent from the Squeak - Beginners mailing list archive at
> Nabble.com.
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners