LWUIT Tab navigation/list focus issue

617 views Asked by At

I have embedded 3 'TABS' on top of a form. Each tab has a 'LIST'. Whenever I change focus from one tab to another, I want my lists to have focus. How do I ensure that my lists always have focus? I navigate using gameKeyEvents. I have added an actionListener to my form for game key events. I cannot override the keyReleased() method of the form as I need to add an action listener to my form(it contains other commands too).

I tried overriding the keyreleased() method of my ‘Tabs’ class , but thats not working(WHY??). Nothing happens.

Tabs holder = new Tabs()
    {
        public void keyReleased(int keyEvent)
    {
    System.out.println("key release is working"); // this statement does not work
    }
      };

When i shift tabs by navigating through left and right keys, my lists lose focus (their selection appears faded) and at other times they hold focus (their selection appears solid.) How do I ensure that my lists always have focus? This is very essential for my program to work. I have attached the snapshots. Please assist.

Please see the attached pictures.

In picture 1, you will see that the list item 3 is highlighted. Now, if I press the left/right/down game keys ...the focus disappears from the list and goes to the tab at 3rd position. I WANT TO PREVENT THIS. (not able to post images cuz am a new user. please check the links)

enter image description here

enter image description here

1

There are 1 answers

0
Shai Almog On BEST ANSWER

Derive the Form and override keyReleased/keyPresed to detect game key right/left.

When you get a right or left key never call super (always call super for other cases).

In the keyPressed method if you get right/left just switch a tab and call the requestFocus() method for the appropriate list.

You need to get the tab buttons from the Tabs component and set them to be focusable false to prevent the list from losing its focus.