aboutsummaryrefslogtreecommitdiff
path: root/tkdnd-plugin.tcl
blob: 90a4aeac9dcf2790989e791efc11e77c72013fc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package require tkdnd

dnd bindtarget .pdwindow text/uri-list <Drop> {
    foreach file %D {open_file $file}
}

bind PatchWindow <<Loaded>> \
    {+dnd bindtarget %W text/uri-list <Drop> "pdtk_canvas_makeobjs %W %%D %%X %%Y"}

proc pdtk_canvas_makeobjs {mytoplevel files x y} {
    set c 0
    set rootx [winfo rootx $mytoplevel]
    set rooty [winfo rooty $mytoplevel]
    for {set n 0} {$n < [llength $files]} {incr n} {
        if {[regexp {.*/(.+).pd$} [lindex $files $n] file obj] == 1} {
            ::pdwindow::error " do it $file $obj $x $y $c"
            pdsend "$mytoplevel obj [expr $x - $rootx] [expr $y - $rooty + ($c * 30)] $obj"
            incr c
        }
    } 
}