[Open] Drag and Drop from Finder

Mac OSX specific forum
User avatar
Shardik
Addict
Addict
Posts: 2060
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: [Open] Drag and Drop from Finder

Post by Shardik »

garretthylltun wrote:Has anyone succeeded in getting drag and drop functionality from Finder
to a PB app?
Wolfram wrote:Hello,

do you get a solution for drag and drop from OSX Finder?
This is actually very simple in PB 5.11 (tested on Snow Leopard 10.6.8 and Mountain Lion 10.8.3 with default subsystem Cocoa x86 + x64 and subsystem Carbon x86; in Carbon even a plus icon is attached to the cursor when above the EditorGadget). Just select one or multiple files in the finder, drag them to the PB window and drop them onto the EditorGadget: the dropped filename(s) will be displayed in the EditorGadget.

Code: Select all

OpenWindow(0, 50, 50, 300, 260, "Drop files from Finder")
StickyWindow(0, #True)
EditorGadget(0, 10, 10, 280, 240)
EnableGadgetDrop(0, #PB_Drop_Files, #PB_Drag_Copy)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_GadgetDrop
      SetGadgetText(0, EventDropFiles())
  EndSelect
ForEver