|
|
Ralf Fassel wrote:
* Ralf Fassel <ralfixx@xxxxxx>
| Subject: Re: invoking
Make that "invoking a proc by space key, but not everywhere".
Or something like that.
R'
This sounds like a real usability nightmare. "Pressing space invokes the
start button, unless you've already pressed the start button in which
case it invokes the stop button. However, it won't invoke either button
if focus is on X and Y, but it will invoke either button if focus is on Z".
Are you _sure_ you want to do this? Why not bind start to F1 and stop to
F2 or something?
To answer your specific question though, I'd do it like this:
bind . <space> maybeInvokeSomething
proc maybeInvokeSomething {} {
# let space be a space in text and entry widgets
set focus [focus]
set class [winfo class $focus]
if {$class ne "Text" && $class ne "Entry"} {
if { ! $isRunning} {
start
} else {
stop
}
} else {
# do nothing
}
}
Of course, what you actually test for should probably be different. For
example, you need to also check for comboboxes or canvases if you allow
entry there. And probably checkbuttons and radiobuttons since space
should do its default thing there, too. And regular buttons since space
should do its default thing there, too (to enable keyboard navigation
for those who can't or choose not to use a mouse). And so on.
You should really rethink this idea of making space do something
different depending on some sort of invisible-to-the-user set of rules.
|
|