Navigating through CForimView controls
-
How to implement movement between button controls placed on a CFormView with arrow keys? Buttons are positioned like chessboard squares - so when the arrow key for left is pressed the focus should move to the button placed left and so on. Should SetFocus() be overriden?
-
How to implement movement between button controls placed on a CFormView with arrow keys? Buttons are positioned like chessboard squares - so when the arrow key for left is pressed the focus should move to the button placed left and so on. Should SetFocus() be overriden?
I have difficulties seeing what
SetFocus
should accomplish :) You can, for example, add the arrow keys as accelerators in the accelerator table and map them to functions in your view. -
I have difficulties seeing what
SetFocus
should accomplish :) You can, for example, add the arrow keys as accelerators in the accelerator table and map them to functions in your view.I just want to move focus from one button to another, so the desired button can be activated by pressing ENTER. It is possible to move focus with TAB key as well as with arrow keys, but focus goes from one button to the other as it was set in Layout -> Tab Order. What I want to accomplish is to move focus in one of four directions using arrow keys, but I am not sure what's the best way to implement this behaviour.
-
I just want to move focus from one button to another, so the desired button can be activated by pressing ENTER. It is possible to move focus with TAB key as well as with arrow keys, but focus goes from one button to the other as it was set in Layout -> Tab Order. What I want to accomplish is to move focus in one of four directions using arrow keys, but I am not sure what's the best way to implement this behaviour.
dart13 wrote: What I want to accomplish is to move focus in one of four directions using arrow keys I understood that much, and I really think that you should try with accelerators. In the view - where you handle the message - you might want to check what control currently has the focus, and change it according to the pattern you want. It is a button having the focus when the key is pressed, and therefore the keypress will be sent to the button (actually, the key up message will be sent... to the button the focus was moved to!). Therefore, the most basic place to handle this would be in a
CButton
-derived class. But it is not a good way to solve the problem! If you try handling the focus setting itself, you'll get into all sorts of grief, as changing the focus in a focus-handler (that is, a handler toWM_SETFOCUS
) will most probably get you in trouble. Furthermore, if you handle this from the buttons themselves, you'll have to post messages to the owner anyway, as an individual button will have no knowledge of the other buttons on the view. So, accelerators!