Patko and I just got TkDND working on Windows and included Pd-extended
0.43.  That means tomorrows nightly build should have it included, and
its ready for scripting with.  TkDND allows Pd to handle drag-n-drop
events, so you can do things like drop a file onto the Pd window to open
it (implemented in the attached plugin) or drop a pd patch onto a canvas
to make an object (also kind of implemented in the plugin).

There are lots of interesting ideas possible, I'm hoping you will play
with it and see what kinds of stuff we can do.  I forgot who originally
implemented the TkDND stuff for Pd, but this is based on that work, so
thanks for that.

.hc
package require tkdnd

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

proc setup_dndbind {mytoplevel} {
    ::pdwindow::error "binding to $mytoplevel"
    dnd bindtarget $mytoplevel text/uri-list <Drop> "pdtk_canvas_makeobjs $mytoplevel %D %x %y"
}
bind PatchWindow <<Loaded>> {+setup_dndbind %W}

proc pdtk_canvas_makeobjs {mytoplevel files x y} {
    set c 0
    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 $x [expr $y + ($c * 30)] $obj"
            incr c
        }
    } 
}
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to