Version 2 of Useful Bind Procedures

Updated 2002-10-02 08:27:52

GPS - Sat Feb 9 2002 - Below are some useful procedures for use with Tk input bindings. Please feel free to add your own. See also bind


  #Updated Oct 2, 2002 

  proc bind:children {win key command} {
    bind $win $key $command

    foreach subWin [winfo children $win] {
      bind:children $subWin $key $command
    }
  }

  proc bind:copyClass {class newClass} {
    foreach binding [bind $class] {
      bind $newClass $binding [bind $class $binding]
    }
  }

  proc bind:removeFromClass {class removeList} {
    foreach item $removeList {
      bind $class <$item> {}
    }
  }

  proc bind:removeAllBut {class bindList} {
    foreach binding $bindList {
      array set tmprab "<${binding}> 0"
    }

    foreach binding [bind $class] {
      if {[info exists tmprab($binding)]} {
        continue
      }
      bind $class $binding {}
    }

    array unset tmprab
  }