From 84fdd43b69b2f7db996fa580f31468bc53e3e848 Mon Sep 17 00:00:00 2001 From: "petasisg@gmail.com" Date: Wed, 4 Mar 2015 11:10:17 +0000 Subject: %x, %y mouse coordinates for drag sources event --- Changelog | 7 ++++++- library/tkdnd.tcl | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Changelog b/Changelog index e5e8507..cc38f39 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,11 @@ -2015-02-25 Petasis George +2015-03-15 Petasis George TkDND 2.8 released. +2015-03-04 Petasis George + * library/tkdnd.tcl: Added support in <> & <> + for %x, %y mouse coordinates (relative to window that is the drag + source). + 2015-02-20 Petasis George * unix/TkDND_XDND.c: Fixed a bug in converting Time to a Tcl object. Now Tcl_NewWideIntObj() is used, as Tcl_NewLongObj() could cause an diff --git a/library/tkdnd.tcl b/library/tkdnd.tcl index 51ed777..c8f05af 100644 --- a/library/tkdnd.tcl +++ b/library/tkdnd.tcl @@ -50,12 +50,12 @@ namespace eval ::tkdnd { variable _windowingsystem - bind TkDND_Drag1 {tkdnd::_begin_drag press 1 %W %s %X %Y} - bind TkDND_Drag1 {tkdnd::_begin_drag motion 1 %W %s %X %Y} - bind TkDND_Drag2 {tkdnd::_begin_drag press 2 %W %s %X %Y} - bind TkDND_Drag2 {tkdnd::_begin_drag motion 2 %W %s %X %Y} - bind TkDND_Drag3 {tkdnd::_begin_drag press 3 %W %s %X %Y} - bind TkDND_Drag3 {tkdnd::_begin_drag motion 3 %W %s %X %Y} + bind TkDND_Drag1 {tkdnd::_begin_drag press 1 %W %s %X %Y %x %y} + bind TkDND_Drag1 {tkdnd::_begin_drag motion 1 %W %s %X %Y %x %y} + bind TkDND_Drag2 {tkdnd::_begin_drag press 2 %W %s %X %Y %x %y} + bind TkDND_Drag2 {tkdnd::_begin_drag motion 2 %W %s %X %Y %x %y} + bind TkDND_Drag3 {tkdnd::_begin_drag press 3 %W %s %X %Y %x %y} + bind TkDND_Drag3 {tkdnd::_begin_drag motion 3 %W %s %X %Y %x %y} # ---------------------------------------------------------------------------- # Command tkdnd::initialise: Initialise the TkDND package. @@ -255,7 +255,7 @@ proc ::tkdnd::drop_target { mode path { types {} } } { # ---------------------------------------------------------------------------- # Command tkdnd::_begin_drag # ---------------------------------------------------------------------------- -proc ::tkdnd::_begin_drag { event button source state X Y } { +proc ::tkdnd::_begin_drag { event button source state X Y x y } { variable _x0 variable _y0 variable _state @@ -275,7 +275,7 @@ proc ::tkdnd::_begin_drag { event button source state X Y } { if { [string equal $_state "press"] } { if { abs($_x0-$X) > 3 || abs($_y0-$Y) > 3 } { set _state "done" - _init_drag $button $source $state $X $Y + _init_drag $button $source $state $X $Y $x $y } } } @@ -285,12 +285,12 @@ proc ::tkdnd::_begin_drag { event button source state X Y } { # ---------------------------------------------------------------------------- # Command tkdnd::_init_drag # ---------------------------------------------------------------------------- -proc ::tkdnd::_init_drag { button source state rootX rootY } { +proc ::tkdnd::_init_drag { button source state rootX rootY X Y } { # Call the <> binding. set cmd [bind $source <>] if {[string length $cmd]} { - set cmd [string map [list %W $source %X $rootX %Y $rootY \ - %S $state %e <> %A \{\} \ + set cmd [string map [list %W $source %X $rootX %Y $rootY %x $X %y $Y \ + %S $state %e <> %A \{\} %% % \ %t [bind $source <>]] $cmd] set info [uplevel \#0 $cmd] set len [llength $info] @@ -334,7 +334,7 @@ proc ::tkdnd::_init_drag { button source state rootX rootY } { } ## Call _end_drag to notify the widget of the result of the drag ## operation... - _end_drag $button $source {} $action {} $data {} $state $rootX $rootY + _end_drag $button $source {} $action {} $data {} $state $rootX $rootY $X $Y } };# tkdnd::_init_drag @@ -348,7 +348,7 @@ proc ::tkdnd::_end_drag { button source target action type data result # Call the <> binding. set cmd [bind $source <>] if {[string length $cmd]} { - set cmd [string map [list %W $source %X $rootX %Y $rootY \ + set cmd [string map [list %W $source %X $rootX %Y $rootY %x $X %y $Y %% % \ %S $state %e <> %A \{$action\}] $cmd] set info [uplevel \#0 $cmd] # if { $info != "" } { -- cgit v0.12