aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2012-11-25 03:54:40 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2012-11-25 03:54:40 +0000
commiteab8eae2f2ef07bb680b73810d024b89829acd68 (patch)
treeb247f55d947bb15bbea54660c24a9fa15ee3062b
parente4e8d0ad257085e2e714b20b09864f4805818b6f (diff)
updated for tkdnd 2.6
svn path=/trunk/scripts/guiplugins/simple_examples/; revision=16578
-rw-r--r--tkdnd-plugin.tcl31
1 files 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 <Drop> {
- foreach file %D {open_file $file}
+namespace eval ::pddnd {
}
-bind PatchWindow <<Loaded>> \
- {+dnd bindtarget %W text/uri-list <Drop> "pdtk_canvas_makeobjs %W %%D %%X %%Y"}
+#------------------------------------------------------------------------------#
+# open all files dropped on the Pd Window
+::tkdnd::drop_target register .pdwindow DND_Files
+bind .pdwindow <<Drop:DND_Files>> {::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 <<Loaded>> {+::pddnd::setup_dndbind %W}
+
+proc ::pddnd::setup_dndbind {mytoplevel} {
+ ::pdwindow::error "setup_dndbind $mytoplevel"
+ ::tkdnd::drop_target register $mytoplevel DND_Files
+ bind $mytoplevel <<Drop:DND_Files>> {::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
}
}