GXT 2.1 - How to disable the default behaviour for HOME and END keys in the TabPanel ?


I have a TabPanel with few tabs, and one of them has a "properties" editor. Some properties are edited using a TextField cotrol, and when I want to go to the beginning or end of the field I press, naturally, the keys HOME or END, and then the TabPanel container changes the selected tab to first one or last one... so I lose my focus on field editing ... very very ugly  indeed ! Workaround is "don't use HOME and END keys", but I can't help it -- I press them all the time :)

Is there a solution for this problem?

The answer for this question is very simple, YES, like the solution itself.


We have to override the "pressed key handler" (good thing that it's protected, and not private), which is providing this ugly behavior, like in this sample code:

public class MyTabPanel extends TabPanel {
     * Override this function to get rid of the HOME, END keys problem.
    protected void onKeyPress (ComponentEvent ce) {
         /* do nothing */

and then use the MyTabPanel instead of the default one. I know, this is an ugly simple solution, but efficient!


No comments:

Post a Comment