Ok, I got it!
I have created a design-time package to illustrate how to capture the
OnKeyDown event of any open SynEdit tab, in a chain (provided by the
TIDESynEditor component), without hacks.
Once my event handler is fired, it processes the key as need, then the next handler is fired automatically (by the chain holder:
TIDESynEditor), all peacefully.
The package keeps track of every editor tab (as desired). Once a editor is created by the IDE, a handler for the target event is registered and a custom object is instantiated (for storing important editor-related data), so that the
OnKeyDown handler can use it (eg: filename, editor control, etc). When the editor tab closes, a cleanup is done (the event handler is unregistered and the custom object is freed).
I've used [
F12] as example (this key was my goal), but it can capture any key, including shift states (CTRL, SHIFT, ALT, etc).
Also interesting to notice is the number of events one can register (see the sources for the
TCustomSynEdit component).
Sample Design-time Package sources:http://www.filedropper.com/lazkeycaptureJust for the records:
I'm running Lazarus 1.6 on Windows 7 32-bit.