thoughts on drag and drop events

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

thoughts on drag and drop events

johnmci
Someone asked about drag and drop of a URL from Safari to Squeak.  
Turns out we get a drag
and drop event with a flavor type of URL, mind we get 7 other flavors  
too, like txt, utf, etc all these
are indicators of an object we want Squeak to process.

Problem is we don't have any way for the VM to feed those back to us  
because the logic is setup
only to consider a file drag/drop event.

So, either I create a file and stuff the data into it, messy but  
would work with existing logic, and have the
drag file dispatcher would need to do the right thing.

Or alter sqDragDropFilesEvent and have a different drag type and pass  
up an object containing the bits in question

Thoughts on the choices are welcome
--
========================================================================
===
John M. McIntosh <[hidden email]> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===

Reply | Threaded
Open this post in threaded view
|

Re: thoughts on drag and drop events

Michael Rueger-6
John M McIntosh wrote:

> Or alter sqDragDropFilesEvent and have a different drag type and pass  
> up an object containing the bits in question
>
> Thoughts on the choices are welcome

We need to extend the mechanism IMO.

Similar problem with clipboards, where you also need to able to iterate
and access *all* the available formats the OS offers?

Michael
Reply | Threaded
Open this post in threaded view
|

Re: thoughts on drag and drop events

johnmci
The clipboard support is easier given we're doing it in FFI for now.  
We can iterate over the types and make decision in Smalltalk code
The drag and drop is more difficult because it's handled mostly by  
the VM. Although we could pass up the drag info and invoke FFI
let me think on that a bit, especially if we want some backward  
compatibility.

On 10-Apr-06, at 1:44 PM, Michael Rueger wrote:

> John M McIntosh wrote:
>
>> Or alter sqDragDropFilesEvent and have a different drag type and  
>> pass  up an object containing the bits in question
>> Thoughts on the choices are welcome
>
> We need to extend the mechanism IMO.
>
> Similar problem with clipboards, where you also need to able to  
> iterate and access *all* the available formats the OS offers?
>
> Michael

--
========================================================================
===
John M. McIntosh <[hidden email]> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===

Reply | Threaded
Open this post in threaded view
|

Re: thoughts on drag and drop events

Andreas.Raab
In reply to this post by johnmci
Hi Guys -

On Windows, what you get is a (set of) format identifier (either one of
the "standard" ones like CF_TEXT, CF_BITMAP, or one of the "private"
ones that applications can register directly) and its interpretation is
up to your app. This is the same between DnD and clipboard, but DnD may
also indicate feedback for the DnD operation (e.g., whether the app can
support the operation, whether it would "move" or "copy" the contents etc).

The interface that I could support most easily would be one where we
query for the available formats and (later) request a byte array
consisting of data in the requested format. Put together, it might look
like here:

* ioGetClipboardFormat(clp,n): Get the n-th format of clipboard data.
   This function is used to enumerate available clipboard formats.
   Arguments:
     clp <Integer> - identifier of clipboard (0 - default)
     n   <Integer> - format index
   Return value:
     format <Integer> - the identifier for the clipboard format
                        returns -1 for last entry

* ioReadClipboard(clp, fmt): Get clipboard data in format "fmt".
   This function answers a byte array consisting of the clipboard data
in the request format.
   Arguments:
     clp <Integer> - identifier of clipboard (0 - default)
     fmt <Integer> - format index
   Return value:
     bytes <ByteArray> - the data read from the clipboard

* ioClearClipboard(clp): Clears the clipboard.
   This function is used to clear the entire clipboard so that
subsequent operations can set multiple formats for the same data.
   Arguments:
     clp <Integer> - identifier of clipboard (0 - default)

* ioAddClipboardData(fmt, data): Add clipboard data in format fmt.
   This function is used for adding clipboard data in the given format.
   Arguments:
     clp  <Integer> - identifier of clipboard (0 - default)
     data <ByteArray> - the data for the clipboard


I'd do the same thing for DnD, e.g.,

* ioGetDropFormat(dh,n): Get the n-th format of drop data
   This function is used to enumerate available drop formats.
   Arguments:
     dh  <Integer> - drop handle
     n   <Integer> - format index
   Return value:
     format <Integer> - the identifier for the drop format
                        returns -1 for last entry

* ioGetDropData(dh, fmt): Get drop data in format "fmt".
   This function answers a byte array consisting of the clipboard data
in the request format.
   Arguments:
     dh  <Integer> - drop handle
     fmt <Integer> - format index
   Return value:
     bytes <ByteArray> - the data read from the drop handle

* ioDeleteDropHandle(dh): Free a drop handle
   This function is necessary since the drop handle will have to be
preserved until the (Squeak) DnD operation is complete which typically
outlasts the OS' transaction.
   Arguments:
     dh  <Integer> - drop handle

* ioSetDropFlags(dh, flags): Set drop flags during drag and drop.
   This function allows us to customize user feedback for the drop.
   Arguments:
     dh    <Integer> - drop handle
     flags <Integer> Either one of "reject drop", "move operation",
"copy operation" etc.

Would this work on other platforms?

Cheers,
   - Andreas

John M McIntosh wrote:

> Someone asked about drag and drop of a URL from Safari to Squeak. Turns
> out we get a drag
> and drop event with a flavor type of URL, mind we get 7 other flavors
> too, like txt, utf, etc all these
> are indicators of an object we want Squeak to process.
>
> Problem is we don't have any way for the VM to feed those back to us
> because the logic is setup
> only to consider a file drag/drop event.
>
> So, either I create a file and stuff the data into it, messy but would
> work with existing logic, and have the
> drag file dispatcher would need to do the right thing.
>
> Or alter sqDragDropFilesEvent and have a different drag type and pass up
> an object containing the bits in question
>
> Thoughts on the choices are welcome
> --
> ===========================================================================
> John M. McIntosh <[hidden email]> 1-800-477-2659
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
>
>
Reply | Threaded
Open this post in threaded view
|

Re: thoughts on drag and drop events

johnmci
This looks ok, lets see about an implementation on the mac for the  
drag/drop.
I note we should use ioSetDropFlags  to tell the vm that the image  
supports the new drag/drop features, versus falling back to the old  
implementation

On 10-Apr-06, at 3:50 PM, Andreas Raab wrote:

> Hi Guys -
>
> On Windows, what you get is a (set of) format identifier (either  
> one of the "standard" ones like CF_TEXT, CF_BITMAP, or one of the  
> "private" ones that applications can register directly) and its  
> interpretation is up to your app. This is the same between DnD and  
> clipboard, but DnD may also indicate feedback for the DnD operation  
> (e.g., whether the app can support the operation, whether it would  
> "move" or "copy" the contents etc).
>
> The interface that I could support most easily would be one where  
> we query for the available formats and (later) request a byte array  
> consisting of data in the requested format. Put together, it might  
> look like here:
>
> * ioGetClipboardFormat(clp,n): Get the n-th format of clipboard data.
>   This function is used to enumerate available clipboard formats.
>   Arguments:
>     clp <Integer> - identifier of clipboard (0 - default)
>     n   <Integer> - format index
>   Return value:
>     format <Integer> - the identifier for the clipboard format
>                        returns -1 for last entry
>
> * ioReadClipboard(clp, fmt): Get clipboard data in format "fmt".
>   This function answers a byte array consisting of the clipboard  
> data in the request format.
>   Arguments:
>     clp <Integer> - identifier of clipboard (0 - default)
>     fmt <Integer> - format index
>   Return value:
>     bytes <ByteArray> - the data read from the clipboard
>
> * ioClearClipboard(clp): Clears the clipboard.
>   This function is used to clear the entire clipboard so that  
> subsequent operations can set multiple formats for the same data.
>   Arguments:
>     clp <Integer> - identifier of clipboard (0 - default)
>
> * ioAddClipboardData(fmt, data): Add clipboard data in format fmt.
>   This function is used for adding clipboard data in the given format.
>   Arguments:
>     clp  <Integer> - identifier of clipboard (0 - default)
>     data <ByteArray> - the data for the clipboard
>
>
> I'd do the same thing for DnD, e.g.,
>
> * ioGetDropFormat(dh,n): Get the n-th format of drop data
>   This function is used to enumerate available drop formats.
>   Arguments:
>     dh  <Integer> - drop handle
>     n   <Integer> - format index
>   Return value:
>     format <Integer> - the identifier for the drop format
>                        returns -1 for last entry
>
> * ioGetDropData(dh, fmt): Get drop data in format "fmt".
>   This function answers a byte array consisting of the clipboard  
> data in the request format.
>   Arguments:
>     dh  <Integer> - drop handle
>     fmt <Integer> - format index
>   Return value:
>     bytes <ByteArray> - the data read from the drop handle
>
> * ioDeleteDropHandle(dh): Free a drop handle
>   This function is necessary since the drop handle will have to be  
> preserved until the (Squeak) DnD operation is complete which  
> typically outlasts the OS' transaction.
>   Arguments:
>     dh  <Integer> - drop handle
>
> * ioSetDropFlags(dh, flags): Set drop flags during drag and drop.
>   This function allows us to customize user feedback for the drop.
>   Arguments:
>     dh    <Integer> - drop handle
>     flags <Integer> Either one of "reject drop", "move operation",  
> "copy operation" etc.
>
> Would this work on other platforms?
>
> Cheers,
>   - Andreas
>
> John M McIntosh wrote:
>> Someone asked about drag and drop of a URL from Safari to Squeak.  
>> Turns out we get a drag
>> and drop event with a flavor type of URL, mind we get 7 other  
>> flavors too, like txt, utf, etc all these
>> are indicators of an object we want Squeak to process.
>> Problem is we don't have any way for the VM to feed those back to  
>> us because the logic is setup
>> only to consider a file drag/drop event.
>> So, either I create a file and stuff the data into it, messy but  
>> would work with existing logic, and have the
>> drag file dispatcher would need to do the right thing.
>> Or alter sqDragDropFilesEvent and have a different drag type and  
>> pass up an object containing the bits in question
>> Thoughts on the choices are welcome
>> --
>> =====================================================================
>> ======
>> John M. McIntosh <[hidden email]> 1-800-477-2659
>> Corporate Smalltalk Consulting Ltd.  http://
>> www.smalltalkconsulting.com
>> =====================================================================
>> ======

--
========================================================================
===
John M. McIntosh <[hidden email]> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===