| 1 |
# |
| 2 |
# dragdrop.tcl |
| 3 |
# |
| 4 |
# ---------------------------------------------------------------------- |
| 5 |
# Bindings for the BLT drag&drop command |
| 6 |
# ---------------------------------------------------------------------- |
| 7 |
# AUTHOR: George Howlett |
| 8 |
# Bell Labs Innovations for Lucent Technologies |
| 9 |
# [email protected] |
| 10 |
# http://www.tcltk.com/blt |
| 11 |
# ---------------------------------------------------------------------- |
| 12 |
# Copyright (c) 1998 Lucent Technologies, Inc. |
| 13 |
# ====================================================================== |
| 14 |
# |
| 15 |
# Permission to use, copy, modify, and distribute this software and its |
| 16 |
# documentation for any purpose and without fee is hereby granted, |
| 17 |
# provided that the above copyright notice appear in all copies and that |
| 18 |
# both that the copyright notice and warranty disclaimer appear in |
| 19 |
# supporting documentation, and that the names of Lucent Technologies |
| 20 |
# any of their entities not be used in advertising or publicity |
| 21 |
# pertaining to distribution of the software without specific, written |
| 22 |
# prior permission. |
| 23 |
# |
| 24 |
# Lucent Technologies disclaims all warranties with regard to this |
| 25 |
# software, including all implied warranties of merchantability and |
| 26 |
# fitness. In no event shall Lucent be liable for any special, indirect |
| 27 |
# or consequential damages or any damages whatsoever resulting from loss |
| 28 |
# of use, data or profits, whether in an action of contract, negligence |
| 29 |
# or other tortuous action, arising out of or in connection with the use |
| 30 |
# or performance of this software. |
| 31 |
# |
| 32 |
# ====================================================================== |
| 33 |
|
| 34 |
if { $tcl_version >= 8.0 } { |
| 35 |
set cmd blt::drag&drop |
| 36 |
} else { |
| 37 |
set cmd drag&drop |
| 38 |
} |
| 39 |
for { set i 1 } { $i <= 5 } { incr i } { |
| 40 |
bind BltDrag&DropButton$i <ButtonPress-$i> [list $cmd drag %W %X %Y] |
| 41 |
bind BltDrag&DropButton$i <B$i-Motion> [list $cmd drag %W %X %Y] |
| 42 |
bind BltDrag&DropButton$i <ButtonRelease-$i> [list $cmd drop %W %X %Y] |
| 43 |
} |
| 44 |
|
| 45 |
# ---------------------------------------------------------------------- |
| 46 |
# |
| 47 |
# Drag&DropInit -- |
| 48 |
# |
| 49 |
# Invoked from C whenever a new drag&drop source is created. |
| 50 |
# Sets up the default bindings for the drag&drop source. |
| 51 |
# |
| 52 |
# <ButtonPress-?> Starts the drag operation. |
| 53 |
# <B?-Motion> Updates the drag. |
| 54 |
# <ButtonRelease-?> Drop the data on the target. |
| 55 |
# |
| 56 |
# Arguments: |
| 57 |
# widget source widget |
| 58 |
# button Mouse button used to activate drag. |
| 59 |
# cmd "dragdrop" or "blt::dragdrop" |
| 60 |
# |
| 61 |
# ---------------------------------------------------------------------- |
| 62 |
|
| 63 |
proc blt::Drag&DropInit { widget button } { |
| 64 |
set tagList {} |
| 65 |
if { $button > 0 } { |
| 66 |
lappend tagList BltDrag&DropButton$button |
| 67 |
} |
| 68 |
foreach tag [bindtags $widget] { |
| 69 |
if { ![string match BltDrag&DropButton* $tag] } { |
| 70 |
lappend tagList $tag |
| 71 |
} |
| 72 |
} |
| 73 |
bindtags $widget $tagList |
| 74 |
} |
| 75 |
|