Board index » cppbuilder » Handling navigation keys in TFrame
jerha202
![]() CBuilder Developer |
Handling navigation keys in TFrame2007-10-14 01:12:50 AM cppbuilder45 Hi all! How do I handle navigation keys (arrow keys, tab et c) when a component inside a TFrame is in focus? Some details about my program: I have a TFrame descendant (TMyFrame) to which I have added a TPaintBox at design time. I also have a TForm descendant (TMyForm) to which I have added a TPageControl. In the program, at run-time, I create an instance of TMyFrame and attach it to a TTabSheet which also has been created dynamically, and then I add the tabsheet to the page control in TMyForm. Now, when the user presses a navigation key, for example an arrow key, and the paintbox is in focus, I would like to handle that keypress somewhere, but I have failed so far. I have tried: * Using a custom TPaintBox component where I have published OnKeyDown, but the handler never gets called. * Assigning OnKeyDown to a handler dynamically in TMyFrame, but that handler never gets called either. * Setting KeyPreview to true in TMyForm and adding an OnKeyDown handler there. Here's where it's getting interesting. If I press a non- navigation key, for example the space key, the handler is always called. But if I press a navigation key, the handler is called only if a component outside the frame is in focus. The case navigation key AND component in frame in focus doesn't work. * Defining an action in TMyForm whose shortcut key is the navigation key I want to handle. This actually works - the action handler is called, but it also consumes the key so that it doesn't work in TEdits et c in other places in the program. I'm using C++Builder 6. Any insight into this problem will be greatly appreciated. |