#!../wafe --f
#
# The following script shows how multiple pointer button clicks can be
# bound to different actions. If the same button has a binding for say
# 1, 2 and 3 times clicking (say, using Xt's repeat count notation)
# and the user clicks three times in a row, the actions for 1, 2 and 3
# times clicking are executed. 
#
# This script shows a simple way to implement that only the binding
# with the highest click count will be executed (i.e. for a triple
# click only the Command associated with the triple click).  Note that
# in "exec(click TclCommand)" the user can specify an arbitary
# TclCommand.
#
# -gustaf neumann                 Fri Nov 26 15:15:26 GMT 1993

mergeResources topLevel \
  *background pink \
  *Text*background gray90 \
  *borderWidth 0

Form f topLevel
Label info f width 400 label {Click with left pointer button below!}
Text t f width 400 fromVert info editType edit \
  translations {#override
    <Btn1Down>(1): exec(click clickAction once)
    <Btn1Down>(2): exec(click clickAction twice)
    <Btn1Down>(3): exec(click clickAction {three times})
  }
realize

set lastClick 0
proc click {cmd args} {
  global lastClick
  addTimeOut 220 "if {\$lastClick==[incr lastClick]} {$cmd $args}"
}
	 
proc clickAction {arg} {
  sV info label "The left pointer button was pressed $arg!"
}
