HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

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

HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Helene Bilbo
I already asked this on Stackoverflow, but as there were no answers, I post the question also here:

I want to build a Morph that accepts the dropping of files and folders onto it and that answers a new FileSystem FileReference for them in Pharo 1.4.

I found the class ExternalDropHandler and the wantsDropFiles: anEvent method in Morph, but it don't know how to put it all together, especially as ExternalDropHandler seems to work still with the old Files file system.

What I did so far:
I made a subclass of Morph and implemented wantsDroppedMorph: aMorph event: evt, wantsDropFiles: anEvent and dropFiles: anEvent and set enableDragNDrop: to True. I open an instance in World and bring the Morph to the front. But, whenever I drop a file or folder onto it, it's the World, instance of PasteUpMorph, that get's to handle the drop (I found out by putting in some self halts) and not my Morph.
Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Stéphane Ducasse
helene did you check on pharo by example because hilaire wrote something on morph drag and dropping a while ago and we used it.
I looked for my little example where I controlled a that a morph would on demand repel a drop or accept it.
I did not check it but here it is
Let me know if it is working for you. first in 1.4 and if you can adapt it for your need.



 

On Aug 14, 2012, at 9:25 PM, Helene Bilbo wrote:

> I already asked this on Stackoverflow, but as there were no answers, I post
> the question also here:
>
> I want to build a Morph that accepts the dropping of files and folders onto
> it and that answers a new FileSystem FileReference for them in Pharo 1.4.
>
> I found the class ExternalDropHandler and the wantsDropFiles: anEvent method
> in Morph, but it don't know how to put it all together, especially as
> ExternalDropHandler seems to work still with the old Files file system.
>
> *What I did so far:*
> I made a subclass of Morph and implemented wantsDroppedMorph: aMorph event:
> evt, wantsDropFiles: anEvent and dropFiles: anEvent and set enableDragNDrop:
> to True. I open an instance in World and bring the Morph to the front. But,
> whenever I drop a file or folder onto it, it's the World, instance of
> PasteUpMorph, that get's to handle the drop (I found out by putting in some
> self halts) and not my Morph.
>
>
>
> --
> View this message in context: http://forum.world.st/HowTo-make-a-Morph-that-accepts-dropped-files-and-folders-and-produces-a-new-FileSystem-FileReferenc4-tp4644119.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


DragAndDropRepel.3.cs (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Helene Bilbo
Stéphane Ducasse wrote
helene did you check on pharo by example because hilaire wrote something on morph drag and dropping a while ago and we used it.
I looked for my little example where I controlled a that a morph would on demand repel a drop or accept it.
I did not check it but here it is
Let me know if it is working for you. first in 1.4 and if you can adapt it for your need.
Yes, what you attached is the example from PBE1. It works perfectly well.

My problem seems to be specific to the case, where a file or folder from outside the Pharo window is dropped on the Morph. In this case it's always the World that gets to handle the drop before my Morph is even asked to do anything about it.
Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Helene Bilbo
I try to implement a UI like the one shown in the image i attach:
Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Stéphane Ducasse
In reply to this post by Helene Bilbo


>
> Stéphane Ducasse wrote
>>
>> helene did you check on pharo by example because hilaire wrote something
>> on morph drag and dropping a while ago and we used it.
>> I looked for my little example where I controlled a that a morph would on
>> demand repel a drop or accept it.
>> I did not check it but here it is
>> Let me know if it is working for you. first in 1.4 and if you can adapt it
>> for your need.
>>
>
> Yes, what you attached is the example from PBE1. It works perfectly well.
>
> My problem seems to be specific to the case, where a file or folder from
> outside the Pharo window is dropped on the Morph. In this case it's always
> the World that gets to handle the drop before my Morph is even asked to do
> anything about it.

Check the code in HandMorph because it is the one that we started to clean with igor (our cleans are not in the image).
But the handmorph has some wonderful case statement that handle the drop from external
Sorry not to be able to be more supportive.

Stef

>
>
>
> --
> View this message in context: http://forum.world.st/HowTo-make-a-Morph-that-accepts-dropped-files-and-folders-and-produces-a-new-FileSystem-FileReferenc4-tp4644119p4644135.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Helene Bilbo
Stéphane Ducasse wrote
> My problem seems to be specific to the case, where a file or folder from
> outside the Pharo window is dropped on the Morph. In this case it's always
> the World that gets to handle the drop before my Morph is even asked to do
> anything about it.

Check the code in HandMorph because it is the one that we started to clean with igor (our cleans are not in the image).
But the handmorph has some wonderful case statement that handle the drop from external
Sorry not to be able to be more supportive.
Thank you for the hint. It seems the problem lies in the fact that a "dropFilesEvent" is different from a "dropEvent" and therefore is not handled by MorphicEventDispatcher>>dispatchDropEvent:with: but by MorphicEventDispatcher>>dispatchEvent:with: and they handle differently which morph may get to process the event.
Still i have not yet a solution ;(

Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Stéphane Ducasse
I do not know more but indeed we will have to clean and simplify that.

STef

On Aug 16, 2012, at 11:24 AM, Helene Bilbo wrote:

>
> Stéphane Ducasse wrote
>>
>>> My problem seems to be specific to the case, where a file or folder from
>>> outside the Pharo window is dropped on the Morph. In this case it's
>>> always
>>> the World that gets to handle the drop before my Morph is even asked to
>>> do
>>> anything about it.
>>
>> Check the code in HandMorph because it is the one that we started to clean
>> with igor (our cleans are not in the image).
>> But the handmorph has some wonderful case statement that handle the drop
>> from external
>> Sorry not to be able to be more supportive.
>>
>
> Thank you for the hint. It seems the problem lies in the fact that a
> "dropFilesEvent" is different from a "dropEvent" and therefore is not
> handled by MorphicEventDispatcher>>dispatchDropEvent:with: but by
> MorphicEventDispatcher>>dispatchEvent:with: and they handle differently
> which morph may get to process the event.
> Still i have not yet a solution ;(
>
> http://forum.world.st/file/n4644226/Bildschirmfoto_2012-08-16_um_11.17.35.png 
>
>
>
> --
> View this message in context: http://forum.world.st/HowTo-make-a-Morph-that-accepts-dropped-files-and-folders-and-produces-a-new-FileSystem-FileReferenc4-tp4644119p4644226.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Denis Kudriashov
In reply to this post by Helene Bilbo
2012/8/16 Helene Bilbo <[hidden email]>

Thank you for the hint. It seems the problem lies in the fact that a
"dropFilesEvent" is different from a "dropEvent" and therefore is not
handled by MorphicEventDispatcher>>dispatchDropEvent:with: but by
MorphicEventDispatcher>>dispatchEvent:with: and they handle differently
which morph may get to process the event.
Still i have not yet a solution ;(

http://forum.world.st/file/n4644226/Bildschirmfoto_2012-08-16_um_11.17.35.png


I'm always wondering when look at such code.
How so many "if statements" can exist at smalltalk system?

Best regards,
Denis


Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Stéphane Ducasse

On Aug 16, 2012, at 12:54 PM, Denis Kudriashov wrote:

> 2012/8/16 Helene Bilbo <[hidden email]>
>
> Thank you for the hint. It seems the problem lies in the fact that a
> "dropFilesEvent" is different from a "dropEvent" and therefore is not
> handled by MorphicEventDispatcher>>dispatchDropEvent:with: but by
> MorphicEventDispatcher>>dispatchEvent:with: and they handle differently
> which morph may get to process the event.
> Still i have not yet a solution ;(
>
> http://forum.world.st/file/n4644226/Bildschirmfoto_2012-08-16_um_11.17.35.png
>
>
> I'm always wondering when look at such code.
> How so many "if statements" can exist at smalltalk system?

we already removed a bunch of them (not there but in the handMorph loop)
but I should continue to work on it to get it ready to integrate.

>
> Best regards,
> Denis
>
>


Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Denis Kudriashov
2012/8/16 Stéphane Ducasse <[hidden email]>

On Aug 16, 2012, at 12:54 PM, Denis Kudriashov wrote:

> 2012/8/16 Helene Bilbo <[hidden email]>
>
> Thank you for the hint. It seems the problem lies in the fact that a
> "dropFilesEvent" is different from a "dropEvent" and therefore is not
> handled by MorphicEventDispatcher>>dispatchDropEvent:with: but by
> MorphicEventDispatcher>>dispatchEvent:with: and they handle differently
> which morph may get to process the event.
> Still i have not yet a solution ;(
>
> http://forum.world.st/file/n4644226/Bildschirmfoto_2012-08-16_um_11.17.35.png
>
>
> I'm always wondering when look at such code.
> How so many "if statements" can exist at smalltalk system?

we already removed a bunch of them (not there but in the handMorph loop)
but I should continue to work on it to get it ready to integrate.


Thank's for all your hard work.
But actualy I wait Shapes framework from Fernando Olivero.

Best regards,
Denis



Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Stéphane Ducasse
> we already removed a bunch of them (not there but in the handMorph loop)
> but I should continue to work on it to get it ready to integrate.
>
>
> Thank's for all your hard work.
> But actualy I wait Shapes framework from Fernando Olivero.

Ok I can understand now I would suggest to help fernando to deliver it and us to integrate it.

Stef
> Best regards,
> Denis
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Ricardo Moran
Hi, maybe my version of Pharo 1.4 is too old (Pharo1.4a Latest update: #14406) or maybe this only works in Windows but I made a morph that handles dropped files by just overriding these two methods:

wantsDropFiles: anEvent
^ true

dropFiles: evt
"Do what you want here"

Cheers,
Richo

On Thu, Aug 16, 2012 at 2:25 PM, Stéphane Ducasse <[hidden email]> wrote:
> we already removed a bunch of them (not there but in the handMorph loop)
> but I should continue to work on it to get it ready to integrate.
>
>
> Thank's for all your hard work.
> But actualy I wait Shapes framework from Fernando Olivero.

Ok I can understand now I would suggest to help fernando to deliver it and us to integrate it.

Stef
> Best regards,
> Denis
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Stéphane Ducasse
it should work since we did not change much in that area.

Stef

On Aug 16, 2012, at 9:29 PM, Ricardo Moran wrote:

> Hi, maybe my version of Pharo 1.4 is too old (Pharo1.4a Latest update: #14406) or maybe this only works in Windows but I made a morph that handles dropped files by just overriding these two methods:
>
> wantsDropFiles: anEvent
> ^ true
>
> dropFiles: evt
> "Do what you want here"
>
> Cheers,
> Richo
>
> On Thu, Aug 16, 2012 at 2:25 PM, Stéphane Ducasse <[hidden email]> wrote:
> > we already removed a bunch of them (not there but in the handMorph loop)
> > but I should continue to work on it to get it ready to integrate.
> >
> >
> > Thank's for all your hard work.
> > But actualy I wait Shapes framework from Fernando Olivero.
>
> Ok I can understand now I would suggest to help fernando to deliver it and us to integrate it.
>
> Stef
> > Best regards,
> > Denis
> >
> >
> >
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Helene Bilbo
In reply to this post by Ricardo Moran
Ricardo Moran wrote
Hi, maybe my version of Pharo 1.4 is too old (Pharo1.4a Latest update:
#14406) or maybe this only works in Windows but I made a morph that handles
dropped files by just overriding these two methods:

wantsDropFiles: anEvent
^ true

dropFiles: evt
"Do what you want here"
That's the first thing i tried. I coudn't find #14406 but i retried in other old builds also in 1.3 but i always have the same problem: Non on the methods in this morph get's ever called, because it is the World (PasteUpMorph) that handles everything, before my morph even get's a chance.

Might it have to do something with the OS? I run on MacOSX.

Or can you share an image where this is working?
Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Ricardo Moran

On Fri, Aug 17, 2012 at 11:34 AM, Helene Bilbo <[hidden email]> wrote:
(...)
Or can you share an image where this is working?


Cheers,
Richo 




--
View this message in context: http://forum.world.st/HowTo-make-a-Morph-that-accepts-dropped-files-and-folders-and-produces-a-new-FileSystem-FileReferenc4-tp4644119p4644424.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Stéphane Ducasse
In reply to this post by Helene Bilbo
helene

once you got was is not working please report to us the solution :)

Stef

On Aug 17, 2012, at 4:34 PM, Helene Bilbo wrote:

>
> Ricardo Moran wrote
>>
>> Hi, maybe my version of Pharo 1.4 is too old (Pharo1.4a Latest update:
>> #14406) or maybe this only works in Windows but I made a morph that
>> handles
>> dropped files by just overriding these two methods:
>>
>> wantsDropFiles: anEvent
>> ^ true
>>
>> dropFiles: evt
>> "Do what you want here"
>>
>
> That's the first thing i tried. I coudn't find #14406 but i retried in other
> old builds also in 1.3 but i always have the same problem: Non on the
> methods in this morph get's ever called, because it is the World
> (PasteUpMorph) that handles everything, before my morph even get's a chance.
>
> Might it have to do something with the OS? I run on MacOSX.
>
> Or can you share an image where this is working?
>
>
>
> --
> View this message in context: http://forum.world.st/HowTo-make-a-Morph-that-accepts-dropped-files-and-folders-and-produces-a-new-FileSystem-FileReferenc4-tp4644119p4644424.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: HowTo make a Morph that accepts dropped files and folders and produces a new FileSystem FileReference in Pharo 1.4

Helene Bilbo
Stéphane Ducasse wrote
once you got was is not working please report to us the solution :)
Ha, it's something totally different than i thought :)))

The only thing Ricardo (Thank you for sharing your image, Ricardo!!) and i did differently was, that he made a real big morph to try it, while i tried with the standard size produced by Morph new.

So the thing to find out now is, when Pharo considers a Cursor/Hand to be above a certain Morph. The arrow beeing completely inside the Morph does not seem to be enough. I will write when i found out more. Or i will be happy if someone already knows about it and can tell me..

helene.