summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpetasisg@gmail.com <petasisg@gmail.com@f3661a36-4baa-549a-d6c7-40e0ffef350e>2014-09-21 07:49:05 (GMT)
committerpetasisg@gmail.com <petasisg@gmail.com@f3661a36-4baa-549a-d6c7-40e0ffef350e>2014-09-21 07:49:05 (GMT)
commitb6dbf97147dbe57d78a5f8d19d64427437ae22a8 (patch)
tree154e867d8889f6385ba656c1963734589ca0cdbe
parent768bc46cdd47acbf861d01532c56548970c1322f (diff)
downloadtkdnd-b6dbf97147dbe57d78a5f8d19d64427437ae22a8.zip
tkdnd-b6dbf97147dbe57d78a5f8d19d64427437ae22a8.tar.gz
tkdnd-b6dbf97147dbe57d78a5f8d19d64427437ae22a8.tar.bz2
Intermediate commit
-rw-r--r--demos/simple_source.tcl6
-rw-r--r--library/tkdnd_macosx.tcl4
-rw-r--r--library/tkdnd_unix.tcl29
-rw-r--r--library/tkdnd_windows.tcl41
-rw-r--r--win/OleDND.h11
5 files changed, 67 insertions, 24 deletions
diff --git a/demos/simple_source.tcl b/demos/simple_source.tcl
index 2cff6d3..b10a70f 100644
--- a/demos/simple_source.tcl
+++ b/demos/simple_source.tcl
@@ -5,9 +5,13 @@ pack [ttk::button .drag_source_text -text " Drag Source (Text) "] \
-fill x -padx 20 -pady 20
pack [ttk::button .drag_source_files -text " Drag Source (Files) "] \
-fill x -padx 20 -pady 20
+pack [ttk::button .drag_source_html -text " Drag Source (HTML) "] \
+ -fill x -padx 20 -pady 20
+
tkdnd::drag_source register .drag_source_text DND_Text
tkdnd::drag_source register .drag_source_files DND_Files
+tkdnd::drag_source register .drag_source_html DND_HTML
## Event <<DragInitCmd>>
set filename [file normalize [info script]]
@@ -15,6 +19,8 @@ bind .drag_source_text <<DragInitCmd>> \
{list copy DND_Text {Some nice dropped text!}}
bind .drag_source_files <<DragInitCmd>> \
{list {copy move} DND_Files [list $filename $filename]}
+bind .drag_source_html <<DragInitCmd>> \
+ {list copy DND_HTML {<html><p>Some nice HTML text!</p></html>}}
## Event <<DragEndCmd>>
bind .drag_source_files <<DragEndCmd>> {
diff --git a/library/tkdnd_macosx.tcl b/library/tkdnd_macosx.tcl
index ce1b224..d92d43f 100644
--- a/library/tkdnd_macosx.tcl
+++ b/library/tkdnd_macosx.tcl
@@ -54,12 +54,12 @@ if {[tk windowingsystem] eq "aqua" && "AppKit" ni [winfo server .]} {
namespace eval macdnd {
variable _dropped_data
-
proc initialise {} {
variable _tkdnd2platform
variable _platform2tkdnd
- ## Initialize the tkdnd 2 platform & platform 2 tkdnd arrays for type conversion...
+ ## Initialize the tkdnd 2 platform & platform 2 tkdnd arrays for
+ ## type conversion...
array set _platform2tkdnd [list \
NSPasteboardTypeString DND_Text \
NSFilenamesPboardType DND_Files \
diff --git a/library/tkdnd_unix.tcl b/library/tkdnd_unix.tcl
index 38cb4bf..34d219e 100644
--- a/library/tkdnd_unix.tcl
+++ b/library/tkdnd_unix.tcl
@@ -67,7 +67,7 @@ namespace eval xdnd {
proc xdnd::_HandleXdndEnter { path drag_source typelist } {
variable _typelist; set _typelist $typelist
variable _pressedkeys; set _pressedkeys 1
- variable _action; set _action {}
+ variable _action; set _action refuse_drop
variable _common_drag_source_types; set _common_drag_source_types {}
variable _common_drop_target_types; set _common_drop_target_types {}
variable _actionlist
@@ -159,7 +159,7 @@ proc xdnd::_HandleXdndPosition { drop_target rootX rootY {drag_source {}} } {
set _drop_target {}
if {[info exists common_drag_source_types]} {
- set _action copy
+ set _action refuse_drop
set _common_drag_source_types $common_drag_source_types
set _common_drop_target_types $common_drop_target_types
set _drop_target $drop_target
@@ -182,15 +182,17 @@ proc xdnd::_HandleXdndPosition { drop_target rootX rootY {drag_source {}} } {
%c \{$_codelist\} %C \{[lindex $_codelist 0]\} \
] $cmd]
set _action [uplevel \#0 $cmd]
+ switch -exact -- $_action {
+ copy - move - link - ask - private - refuse_drop - default {}
+ default {set _action copy}
+ }
}
}
set _drop_target $drop_target
}
- set _action refuse_drop
set _drop_target {}
if {[info exists common_drag_source_types]} {
- set _action copy
set _common_drag_source_types $common_drag_source_types
set _common_drop_target_types $common_drop_target_types
set _drop_target $drop_target
@@ -215,6 +217,10 @@ proc xdnd::_HandleXdndPosition { drop_target rootX rootY {drag_source {}} } {
}
# Return values: copy, move, link, ask, private, refuse_drop, default
# debug "xdnd::_HandleXdndPosition: ACTION: $_action"
+ switch -exact -- $_action {
+ copy - move - link - ask - private - refuse_drop - default {}
+ default {set _action copy}
+ }
return $_action
};# xdnd::_HandleXdndPosition
@@ -309,7 +315,13 @@ proc xdnd::_HandleXdndDrop { time } {
%t \{$_typelist\} %T \{[lindex $_common_drag_source_types 0]\} \
%c \{$_codelist\} %C \{[lindex $_codelist 0]\} \
] $cmd]
- return [uplevel \#0 $cmd]
+ set _action [uplevel \#0 $cmd]
+ # Return values: copy, move, link, ask, private, refuse_drop
+ switch -exact -- $_action {
+ copy - move - link - ask - private - refuse_drop - default {}
+ default {set _action copy}
+ }
+ return $_action
}
}
set cmd [bind $_drop_target <<Drop>>]
@@ -329,8 +341,11 @@ proc xdnd::_HandleXdndDrop { time } {
] $cmd]
set _action [uplevel \#0 $cmd]
}
- # Return values: XdndActionCopy, XdndActionMove, XdndActionLink,
- # XdndActionAsk, XdndActionPrivate, refuse_drop
+ # Return values: copy, move, link, ask, private, refuse_drop
+ switch -exact -- $_action {
+ copy - move - link - ask - private - refuse_drop - default {}
+ default {set _action copy}
+ }
return $_action
};# xdnd::_HandleXdndDrop
diff --git a/library/tkdnd_windows.tcl b/library/tkdnd_windows.tcl
index b1a8268..312d08e 100644
--- a/library/tkdnd_windows.tcl
+++ b/library/tkdnd_windows.tcl
@@ -63,16 +63,16 @@ proc olednd::_HandleDragEnter { drop_target typelist actionlist pressedkeys
variable _codelist; set _codelist $codelist
variable _actionlist; set _actionlist $actionlist
variable _pressedkeys; set _pressedkeys $pressedkeys
- variable _action; set _action {}
+ variable _action; set _action refuse_drop
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"
+ # puts "olednd::_HandleDragEnter: drop_target=$drop_target,\
+ # typelist=$typelist, actionlist=$actionlist,\
+ # pressedkeys=$pressedkeys, rootX=$rootX, rootY=$rootY"
focus $drop_target
## Does the new drop target support any of our new types?
@@ -90,9 +90,7 @@ proc olednd::_HandleDragEnter { drop_target typelist actionlist pressedkeys
}
}
- set _action refuse_drop
if {[info exists common_drag_source_types]} {
- set _action copy
set _common_drag_source_types $common_drag_source_types
set _common_drop_target_types $common_drop_target_types
## Drop target supports at least one type. Send a <<DropEnter>>.
@@ -115,6 +113,10 @@ proc olednd::_HandleDragEnter { drop_target typelist actionlist pressedkeys
}
if {$::tkdnd::_auto_update} {update}
# Return values: copy, move, link, ask, private, refuse_drop, default
+ switch -exact -- $_action {
+ copy - move - link - ask - private - refuse_drop - default {}
+ default {set _action copy}
+ }
return $_action
};# olednd::_HandleDragEnter
@@ -157,6 +159,10 @@ proc olednd::_HandleDragOver { drop_target pressedkeys rootX rootY } {
}
if {$::tkdnd::_auto_update} {update}
# Return values: copy, move, link, ask, private, refuse_drop, default
+ switch -exact -- $_action {
+ copy - move - link - ask - private - refuse_drop - default {}
+ default {set _action copy}
+ }
return $_action
};# olednd::_HandleDragOver
@@ -176,10 +182,6 @@ proc olednd::_HandleDragLeave { drop_target } {
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} {
- set $var {}
- }
set cmd [bind $drop_target <<DropLeave>>]
if {[string length $cmd]} {
@@ -196,9 +198,13 @@ proc olednd::_HandleDragLeave { drop_target } {
%t \{$_typelist\} %T \{[lindex $_common_drag_source_types 0]\} \
%u \{$_codelist\} %C \{[lindex $_codelist 0]\} \
] $cmd]
- set _action [uplevel \#0 $cmd]
+ uplevel \#0 $cmd
}
if {$::tkdnd::_auto_update} {update}
+ foreach var {_types _typelist _actionlist _pressedkeys _action
+ _common_drag_source_types _common_drop_target_types} {
+ set $var {}
+ }
};# olednd::_HandleDragLeave
# ----------------------------------------------------------------------------
@@ -237,7 +243,14 @@ proc olednd::_HandleDrop { drop_target pressedkeys rootX rootY _type data } {
%t \{$_typelist\} %T \{[lindex $_common_drag_source_types 0]\} \
%c \{$_codelist\} %C \{[lindex $_codelist 0]\} \
] $cmd]
- return [uplevel \#0 $cmd]
+ set _action [uplevel \#0 $cmd]
+ # Return values: copy, move, link, ask, private, refuse_drop
+ switch -exact -- $_action {
+ copy - move - link - ask - private - refuse_drop - default {}
+ default {set _action copy}
+ }
+ if {$::tkdnd::_auto_update} {update}
+ return $_action
}
}
set cmd [bind $drop_target <<Drop>>]
@@ -258,6 +271,10 @@ proc olednd::_HandleDrop { drop_target pressedkeys rootX rootY _type data } {
}
if {$::tkdnd::_auto_update} {update}
# Return values: copy, move, link, ask, private, refuse_drop
+ switch -exact -- $_action {
+ copy - move - link - ask - private - refuse_drop - default {}
+ default {set _action copy}
+ }
return $_action
};# olednd::_HandleXdndDrop
diff --git a/win/OleDND.h b/win/OleDND.h
index 807a8d5..e20382f 100644
--- a/win/OleDND.h
+++ b/win/OleDND.h
@@ -572,7 +572,7 @@ class TkDND_DropTarget: public IDropTarget {
status = Tcl_GetIndexFromObj(interp, result, (const char **)DropActions,
"dropactions", 0, &index);
Tcl_DecrRefCount(result);
- if (status != TCL_OK) index = ActionDefault;
+ if (status != TCL_OK) index = (enum dropactions) ActionDefault;
}
switch ((enum dropactions) index) {
case ActionCopy: effect = DROPEFFECT_COPY; break;
@@ -615,7 +615,7 @@ class TkDND_DropTarget: public IDropTarget {
status = Tcl_GetIndexFromObj(interp, result, (const char **)DropActions,
"dropactions", 0, &index);
Tcl_DecrRefCount(result);
- if (status != TCL_OK) index = ActionDefault;
+ if (status != TCL_OK) index = (enum dropactions) ActionDefault;
}
switch ((enum dropactions) index) {
case ActionCopy: effect = DROPEFFECT_COPY; break;
@@ -660,7 +660,7 @@ class TkDND_DropTarget: public IDropTarget {
status = Tcl_GetIndexFromObj(interp, result, (const char **)DropActions,
"dropactions", 0, &index);
Tcl_DecrRefCount(result);
- if (status != TCL_OK) index = ActionDefault;
+ if (status != TCL_OK) index = (enum dropactions) ActionDefault;
}
switch ((enum dropactions) index) {
case ActionCopy: effect = DROPEFFECT_COPY; break;
@@ -716,6 +716,7 @@ class TkDND_DropTarget: public IDropTarget {
typelist = Tcl_NewListObj(0, NULL); Tcl_IncrRefCount(typelist);
actionlist = Tcl_NewListObj(0, NULL); Tcl_IncrRefCount(actionlist);
codelist = Tcl_NewListObj(0, NULL); Tcl_IncrRefCount(codelist);
+ drop_active = false;
/*
* Get the types supported by the drag source.
@@ -754,6 +755,7 @@ class TkDND_DropTarget: public IDropTarget {
* This event will be delivered when the mouse is over tkwin. Ensure that
* the part the mouse is in, is not overlapped by another window...
*/
+#if 0
if (Tk_CoordsToWindow(pt.x, pt.y, tkwin) != tkwin) {
SendDragLeave();
*pdwEffect = DROPEFFECT_NONE;
@@ -761,6 +763,9 @@ class TkDND_DropTarget: public IDropTarget {
SendDragEnter(pt, grfKeyState);
*pdwEffect = SendDragOver(pt, grfKeyState);
}
+#else
+ *pdwEffect = SendDragOver(pt, grfKeyState);
+#endif
return S_OK;
}; /* DragOver */