diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2012-11-25 05:08:24 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2012-11-25 05:08:24 +0000 |
commit | 66c7a05ffae88f4ccbc81418b7d22f3ba19bc389 (patch) | |
tree | f19dad4c288a073e259e3cf10858dcde1e258b89 |
first working sketches of new Drag-n-Drop behaviors with tkdndHEADsvn2git-rootsvn2git-headscripts/guiplugins/dropsuite-plugin
svn path=/trunk/scripts/guiplugins/dropsuite-plugin/; revision=16580
-rw-r--r-- | patches-on-pdwindow-plugin.tcl | 16 | ||||
-rw-r--r-- | text-onto-patch-plugin.tcl | 37 |
2 files changed, 53 insertions, 0 deletions
diff --git a/patches-on-pdwindow-plugin.tcl b/patches-on-pdwindow-plugin.tcl new file mode 100644 index 0000000..c363a30 --- /dev/null +++ b/patches-on-pdwindow-plugin.tcl @@ -0,0 +1,16 @@ +# open all files dropped on the Pd Window + +package require tkdnd + +namespace eval ::patches_on_pdwindow { +} + +::tkdnd::drop_target register .pdwindow DND_Files +bind .pdwindow <<Drop:DND_Files>> {::patches_on_pdwindow::open_dropped_files %D} + +proc ::patches_on_pdwindow::open_dropped_files {files} { + foreach file $files { + open_file $file + } + return "link" +} diff --git a/text-onto-patch-plugin.tcl b/text-onto-patch-plugin.tcl new file mode 100644 index 0000000..87df89b --- /dev/null +++ b/text-onto-patch-plugin.tcl @@ -0,0 +1,37 @@ +package require tkdnd + +namespace eval ::text_on_patch { + variable x 0 + variable y 0 +} + +#------------------------------------------------------------------------------# +# create an object using the dropped filename + +bind PatchWindow <<Loaded>> {+::text_on_patch::bind_to_dropped_text %W} + +proc ::text_on_patch::bind_to_dropped_text {mytoplevel} { + ::tkdnd::drop_target register $mytoplevel DND_Text + bind $mytoplevel <<DropPosition>> {::text_on_patch::setxy %X %Y} + bind $mytoplevel <<Drop:DND_Text>> {::text_on_patch::make_comments %W %D} + # TODO bind to DropEnter and DropLeave to make window visually show whether it will accept the drop or not +} + +proc ::text_on_patch::setxy {newx newy} { + variable x $newx + variable y $newy + return "copy" +} + +proc ::text_on_patch::make_comments {mytoplevel text} { + variable x + variable y + pdwindow::error "::text_on_patch::make_comments $mytoplevel text $x $y" + foreach line [split [regsub {\\\;} $text {}] "\n"] { + if {$line ne ""} { + pdsend "$mytoplevel text $x $y $line" + set y [expr $y + 20] + } + } + return "copy" +} |