From eab8eae2f2ef07bb680b73810d024b89829acd68 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sun, 25 Nov 2012 03:54:40 +0000 Subject: updated for tkdnd 2.6 svn path=/trunk/scripts/guiplugins/simple_examples/; revision=16578 --- tkdnd-plugin.tcl | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tkdnd-plugin.tcl b/tkdnd-plugin.tcl index 90a4aea..06a6e76 100644 --- a/tkdnd-plugin.tcl +++ b/tkdnd-plugin.tcl @@ -1,20 +1,35 @@ package require tkdnd -dnd bindtarget .pdwindow text/uri-list { - foreach file %D {open_file $file} +namespace eval ::pddnd { } -bind PatchWindow <> \ - {+dnd bindtarget %W text/uri-list "pdtk_canvas_makeobjs %W %%D %%X %%Y"} +#------------------------------------------------------------------------------# +# open all files dropped on the Pd Window +::tkdnd::drop_target register .pdwindow DND_Files +bind .pdwindow <> {::pddnd::open_dropped_files %D} -proc pdtk_canvas_makeobjs {mytoplevel files x y} { +proc ::pddnd::open_dropped_files {files} { + foreach file $files {open_file $file} + return "link" +} + +#------------------------------------------------------------------------------# +# create an object using the dropped filename + +bind PatchWindow <> {+::pddnd::setup_dndbind %W} + +proc ::pddnd::setup_dndbind {mytoplevel} { + ::pdwindow::error "setup_dndbind $mytoplevel" + ::tkdnd::drop_target register $mytoplevel DND_Files + bind $mytoplevel <> {::pddnd::pdtk_canvas_makeobjs %W %D %X %Y} +} + +proc ::pddnd::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" + pdsend "$mytoplevel obj $x [expr $y + ($c * 30)] $obj" incr c } } -- cgit v1.2.1