zoukankan      html  css  js  c++  java
  • gesture

    proc gesture_init {w} {
        bind $w <1>               "gesture_start $w %x %y"
        bind $w <B1-Motion>       "gesture_move $w %x %y"
        bind $w <ButtonRelease-1> "gesture_end $w"
     }

     proc gesture_start {w x y} {
        global $w.GestureX $w.GestureY $w.Dirs
        set $w.GestureX $x
        set $w.GestureY $y
        set $w.Dirs ""
     }

     proc gesture_move {w x y} {
        global $w.GestureX $w.GestureY $w.Dirs
        set dx [expr {$x-[set $w.GestureX]}]
        set dy [expr {$y-[set $w.GestureY]}]
        if {abs($dx)+abs($dy) < 20} return
        if {[expr {abs(abs($dx)-abs($dy))}] < 10} return
        set dir [expr {abs($dx) > abs($dy) ? ($dx>0?"R":"L") : ($dy>0?"D":"U")}]
        if {$dir != [lindex [set $w.Dirs] end]} {
            lappend $w.Dirs $dir
        }
        $w create line [set $w.GestureX] [set $w.GestureY] $x $y -tags GESTURE
        set $w.GestureX $x
        set $w.GestureY $y
     }

     proc gesture_end {w} {
        global $w.Dirs
        $w delete GESTURE
        puts [set $w.Dirs]
     }

     pack [label .l -textvariable .c.Dirs] -fill both
     pack [canvas .c] -fill both -expand 1
     gesture_init .c

  • 相关阅读:
    【PAT】1001 害死人不偿命的(3n+1)猜想(动态更新)
    文件指令集
    近距离接触电脑
    文件管理
    文件写作方法
    文件读取方法
    打开文件的逻辑
    话术库
    max的逻辑
    抽象化指令
  • 原文地址:https://www.cnblogs.com/greencolor/p/2154238.html
Copyright © 2011-2022 走看看