changeset 822:b7e1d080ef64

ability to abort a registered drag action Ignore-this: 281c88d9dc644c3d2ac59f5c1e67e75d
author drewp@bigasterisk.com
date Tue, 15 Jan 2013 21:04:50 +0000
parents 295b867fd810
children eefe63581d35
files light9/tkdnd.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/light9/tkdnd.py	Tue Jan 15 21:02:08 2013 +0000
+++ b/light9/tkdnd.py	Tue Jan 15 21:04:50 2013 +0000
@@ -72,7 +72,9 @@
                        action='copy', datatype='text/uri-list', data=''):
     """
     if the 'data' param is callable, it will be called every time to
-    look up the current data
+    look up the current data.
+
+    If the callable returns None (or data is None to begin with), the drag
     """
     widget.tk.call('tkdnd::drag_source', 'register', widget._w)
 
@@ -82,9 +84,12 @@
     # but I don't block my tuple from getting returned (as a tcl list)
 
     def init():
-        return (action, datatype, data() if callable(data) else data)
-    
-    funcId = widget._register(init, 
+        dataValue = data() if callable(data) else data
+        if dataValue is None:
+            return
+        return (action, datatype, dataValue)
+
+    funcId = widget._register(init,
                               widget._substitute,
                               1 # needscleanup
                               )