File: bug40.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 (40 lines) | stat: -rw-r--r-- 1,058 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
29
30
31
32
33
34
35
36
37
38
39
40
 #!/usr/bin/env wish

set ::TKDND_DEBUG_LEVEL 1
package require tkdnd

proc drag_init {} {
    return {copy DND_Text some_data}
}

proc modal_dialog {} {
    set w .modal_dialog
    toplevel $w
    wm title $w "Modal Dialog"
    set text \
        "DnD Source in Modal Dialog:\n\
         (1) Press mouse button here\n\
         (2) Move the mouse around until DnD cursor occurs\n\
         (3) Release the mouse\n\
         ==> Unable to get keyboard focus in other applications until\n\
         (a) the modal dialog is closed, or\n\
         (b) this label is clicked."
    ttk::label $w.source -text $text
    pack $w.source -expand 1 -fill both

    tkdnd::drag_source register $w.source
    bind $w.source <<DragInitCmd>> {drag_init}

    wm transient $w .
    raise $w
    focus $w
    grab  $w
    set sentinel {}
    wm protocol $w WM_DELETE_WINDOW [list set sentinel "closed"]
    tkwait variable sentinel
    grab release $w
    destroy $w
}

ttk::button .button -text "Open Modal Dialog" -command "modal_dialog"
pack .button -expand 1 -fill both