realbasic-nug
[Top] [All Lists]

Filedrag from one RB app to another doesn't work on Windows

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Filedrag from one RB app to another doesn't work on Windows
From: Roger Meier <rb@the-meiers.org>
Date: Tue, 30 Jun 2009 19:29:32 -0700
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
I came across this problem today and it drives me nuts. I have an app with a canvas. I implemented code that allow dragging a BMP from the canvas to other applications that accept picture filedrops such as Gimp, Photoshop, Paintshop Pro, etc. This all works fine on both Mac and Windows. However, this doesn't seem to work when dragging the file to another RB application, and only on Windows, Mac works fine. I don't know if I'm doing something wrong, or if this is a bug.

Here is a simple way to replicate what I'm doing:

   1. Create a new empty project.
2. Add 2 Canvases to Window1, named Canvas1 and Canvas2. Make them about 200x200 pixels each and place them next to each other. 3. Add a Filetype set to the project (called FileTypes1) and add a common filetype for "special/any" to that set.
   4. Add the following code to Canvas1.Open:

      dim w as integer = me.Width
      dim h as integer = me.Height
      dim p as Picture = NewPicture(w,h,32)
      dim g as Graphics = p.Graphics
      g.ForeColor = &cffffff
      g.FillRect 0, 0,w,h
      g.ForeColor = &cff0000
      g.FillOval 0,0,w,h
      me.Backdrop = p

   5. Add the following code to Canvas1.MouseDown:

dim d as DragItem = NewDragItem(me.Left, me.top, me.Width, me.Height)
      dim f as FolderItem = SpecialFolder.Temporary.Child("test.bmp")
      if not (f is nil) then
        f.SaveAsPicture(me.Backdrop, f.SaveAsWindowsBMP)
        d.FolderItem = f
      else
        Return true
      end if
      d.drag
      return true

   6. Add the following code to Canvas2.Open:

      me.AcceptFileDrop(FileTypes1.Any)

   7. Add the following code to Canvas2.DropObject:

if obj.FolderItemAvailable then me.Backdrop = obj.FolderItem.OpenAsPicture

8. To make sure that everything works, run the project and drag the picture of the red dot from one canvas to the other. The red dot should appear in the other canvas. This works on both Mac and Windows. 9. Now create a second instance of the project by either compiling it to an executable and running that or by creating another empty project and repeating the above. 10. Run both instances and drag the red dot in Canvas1 from one instance to the other. Everything works as expected on Mac, but on Windows it doesn't. Set a breakpoint in Canvas2.DropObject in the second instance (the one that receives the drop). On Windows, the event occurs, but Obj.FolderItem is nil.


It is possible to drag the red dot to other applications on both platforms as long as they are not RB applications. If the application receiving the drop is an RB application it doesn't work on Windows. Furthermore, it works on both platforms when the drop is received in the same application where the drag started.

Am I missing something here? AFAIK this should work without a problem. Has anyone who implemented something like this before any wisdom to share?

Any insight will be highly appreciated.



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>
  • Filedrag from one RB app to another doesn't work on Windows, Roger Meier <=