It would be useful to be able to define handlers for key presses on a
per-control basis. For example, it is common to end text entry with a press
of the "Enter" key; the action on that key press could be different
depending on the control. I have tried to define different accelerator
tables for different controls, but that doesn't work. Is this something that
is broken, hasn't yet been implemented or is that way by design? I see that
there is an {-accel} key for every control's hash, but I haven't figured out
how to use it.

 

I have also tried to handle the "KeyUp/KeyDown" events, but they don't ever
seem to fire. To which controls do those events apply?

 

The only way I have found to do this is to define a window-level accelerator
table and perform the relevant action depending on which control has focus.
That's ugly and it's a pain to get the control's name from its handle
(perhaps that would be a useful method to build into the module). Even that
is not trivial in the case of, say, a combobox, where it isn't the combobox
itself that has focus, but the dynamically created child edit control.

 

Has anybody come up with an elegant solution for this?

 

Glenn

Reply via email to