File: simple_source.tcl

package info (click to toggle)
tkdnd 2.9.5-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,140 kB
  • sloc: tcl: 2,201; ansic: 2,110; cpp: 1,501; objc: 1,202; sh: 856; makefile: 56
file content (28 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package require tkdnd
catch {console show}

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]]
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>> {
  puts "Drop action: %A"
}