Say you have a Button that uses the -armcommand -
repeatdelay -repeatinterval commands:
Button .vol.up -image imgvolup -borderwidth 0 -
highlightthickness 0 -repeatdelay 700 -repeatinterval
200 -armcommand {VolUp}
(Note: VolUp just increses by 1 the volume)
If you press the .vol.up button repeatedly then hold it
down it goes much faster than it should. I think it is
because the after $delay "Button::_repeat $path" delay
command is never cancelled when the button is
released.
I was trying to fix this and was able to do that in
button.tcl in the Button::_release procedure. I just
added an after cancel command and it appeared to fix
the problem:
proc Button::_release { path } {
variable _current
variable _pressed
if { $_pressed == $path } {
set _pressed ""
set relief [Widget::getMegawidgetOption $path -
relief]
#####################
after cancel "Button::_repeat $path"
#####################
if { ![string compare $relief "link"] } {
set relief raised
}
$path:cmd configure -relief $relief
set cmd [Widget::getMegawidgetOption
$path -disarmcommand]
if { $cmd != "" } {
uplevel \#0 $cmd
}
if { $_current == $path &&
[string compare [$path:cmd cget -
state] "disabled"] && \
[set cmd [Widget::getMegawidgetOption
$path -command]] != "" } {
uplevel \#0 $cmd
}
}
}
|