aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-09-19 17:26:23 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-09-19 17:26:23 +0000
commite4e8d0ad257085e2e714b20b09864f4805818b6f (patch)
tree106c8af17e076c2e1065ea73c382d4e55f92dc62
parenta1ec9f35b48fe28370c5f7b16d5dc8a450ba24a0 (diff)
simple sketch for adding drag-n-drop behavior to the Pd window and canvas windows
svn path=/trunk/scripts/guiplugins/simple_examples/; revision=15310
-rw-r--r--tkdnd-plugin.tcl21
1 files changed, 21 insertions, 0 deletions
diff --git a/tkdnd-plugin.tcl b/tkdnd-plugin.tcl
new file mode 100644
index 0000000..90a4aea
--- /dev/null
+++ b/tkdnd-plugin.tcl
@@ -0,0 +1,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
+ }
+ }
+}