diff options
author | petasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e> | 2012-11-27 18:52:35 (GMT) |
---|---|---|
committer | petasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e> | 2012-11-27 18:52:35 (GMT) |
commit | 9dfeac405ca61c25ea88efba2be219a4acea295d (patch) | |
tree | c39576d2ea35fc020d5f37438510928fdab69f02 /library | |
parent | 4035a38e552ebb50a78905de531a47ff4f9ea1e7 (diff) | |
download | tkdnd-9dfeac405ca61c25ea88efba2be219a4acea295d.zip tkdnd-9dfeac405ca61c25ea88efba2be219a4acea295d.tar.gz tkdnd-9dfeac405ca61c25ea88efba2be219a4acea295d.tar.bz2 |
XDND: %X & %Y for drop events
Diffstat (limited to 'library')
-rw-r--r-- | library/tkdnd_unix.tcl | 21 | ||||
-rw-r--r-- | library/tkdnd_windows.tcl | 17 |
2 files changed, 34 insertions, 4 deletions
diff --git a/library/tkdnd_unix.tcl b/library/tkdnd_unix.tcl index 811fa88..2f3b6c9 100644 --- a/library/tkdnd_unix.tcl +++ b/library/tkdnd_unix.tcl @@ -50,6 +50,9 @@ namespace eval xdnd { variable _dragging 0 + variable _last_mouse_root_x 0 + variable _last_mouse_root_y 0 + proc debug {msg} { puts $msg };# debug @@ -69,6 +72,9 @@ proc xdnd::_HandleXdndEnter { path drag_source typelist } { variable _drop_target; set _drop_target {} variable _actionlist; set _actionlist \ {copy move link ask private} + + variable _last_mouse_root_x; set _last_mouse_root_x 0 + variable _last_mouse_root_y; set _last_mouse_root_y 0 # debug "\n===============================================================" # debug "xdnd::_HandleXdndEnter: path=$path, drag_source=$drag_source,\ # typelist=$typelist" @@ -89,6 +95,10 @@ proc xdnd::_HandleXdndPosition { drop_target rootX rootY {drag_source {}} } { variable _common_drop_target_types variable _drag_source variable _drop_target + + variable _last_mouse_root_x; set _last_mouse_root_x $rootX + variable _last_mouse_root_y; set _last_mouse_root_y $rootY + # debug "xdnd::_HandleXdndPosition: drop_target=$drop_target,\ # _drop_target=$_drop_target, rootX=$rootX, rootY=$rootY" @@ -215,13 +225,16 @@ proc xdnd::_HandleXdndLeave { } { variable _common_drop_target_types variable _drag_source variable _drop_target + variable _last_mouse_root_x + variable _last_mouse_root_y if {![info exists _drop_target]} {set _drop_target {}} # debug "xdnd::_HandleXdndLeave: _drop_target=$_drop_target" if {[info exists _drop_target] && [string length $_drop_target]} { set cmd [bind $_drop_target <<DropLeave>>] if {[string length $cmd]} { set _codelist $_typelist - set cmd [string map [list %W $_drop_target %X 0 %Y 0 \ + set cmd [string map [list %W $_drop_target \ + %X $_last_mouse_root_x %Y $_last_mouse_root_y \ %CST \{$_common_drag_source_types\} \ %CTT \{$_common_drop_target_types\} \ %ST \{$_typelist\} %TT \{$_types\} \ @@ -255,8 +268,10 @@ proc xdnd::_HandleXdndDrop { time } { variable _common_drop_target_types variable _drag_source variable _drop_target - set rootX 0 - set rootY 0 + variable _last_mouse_root_x + variable _last_mouse_root_y + set rootX $_last_mouse_root_x + set rootY $_last_mouse_root_y # puts "xdnd::_HandleXdndDrop: $time" diff --git a/library/tkdnd_windows.tcl b/library/tkdnd_windows.tcl index 32b0187..d839216 100644 --- a/library/tkdnd_windows.tcl +++ b/library/tkdnd_windows.tcl @@ -46,6 +46,9 @@ namespace eval olednd { variable _common_drag_source_types {} variable _common_drop_target_types {} variable _unhandled_types {} + + variable _last_mouse_root_x 0 + variable _last_mouse_root_y 0 };# namespace olednd # ---------------------------------------------------------------------------- @@ -60,6 +63,10 @@ proc olednd::_HandleDragEnter { drop_target typelist actionlist pressedkeys variable _action; set _action {} variable _common_drag_source_types; set _common_drag_source_types {} variable _common_drop_target_types; set _common_drop_target_types {} + + variable _last_mouse_root_x; set _last_mouse_root_x $rootX + variable _last_mouse_root_y; set _last_mouse_root_y $rootY + # puts "olednd::_HandleDragEnter: drop_target=$drop_target,\ # typelist=$typelist, actionlist=$actionlist,\ # pressedkeys=$pressedkeys, rootX=$rootX, rootY=$rootY" @@ -119,6 +126,10 @@ proc olednd::_HandleDragOver { drop_target pressedkeys rootX rootY } { variable _action variable _common_drag_source_types variable _common_drop_target_types + + variable _last_mouse_root_x; set _last_mouse_root_x $rootX + variable _last_mouse_root_y; set _last_mouse_root_y $rootY + # puts "olednd::_HandleDragOver: drop_target=$drop_target,\ # pressedkeys=$pressedkeys, rootX=$rootX, rootY=$rootY" @@ -156,6 +167,9 @@ proc olednd::_HandleDragLeave { drop_target } { variable _action variable _common_drag_source_types variable _common_drop_target_types + variable _last_mouse_root_x + variable _last_mouse_root_y + if {![llength $_common_drag_source_types]} {return} foreach var {_types _typelist _actionlist _pressedkeys _action _common_drag_source_types _common_drop_target_types} { @@ -164,7 +178,8 @@ proc olednd::_HandleDragLeave { drop_target } { set cmd [bind $drop_target <<DropLeave>>] if {[string length $cmd]} { - set cmd [string map [list %W $drop_target %X 0 %Y 0 \ + set cmd [string map [list %W $drop_target \ + %X $_last_mouse_root_x %Y $_last_mouse_root_y \ %CST \{$_common_drag_source_types\} \ %CTT \{$_common_drop_target_types\} \ %ST \{$_typelist\} %TT \{$_types\} \ |