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

  • 相关阅读:
    实现JavaScript自定义函数的整合、链式调用及类的封装
    jQuery事件
    jQuery特效
    jQuery基础细节
    CSS3盒模型
    主流清浮动方法
    JavaScript 执行环境及作用域
    JavaScript 参数传递与变量复制
    PHP雪花背景验证码
    Linkis 0.9.2 版本发布
  • 原文地址:https://www.cnblogs.com/greencolor/p/2154238.html
Copyright © 2011-2022 走看看