java-melwuitlwuit-resource-editor

In Lwuit, How to handle Keypad navigation Events?


In the application I'm building I have Tabs and a list in for each Tab. the behavior I want is when I press the Left/Right Nav Key the selected Tab will change. when I press the Up/Down Nav Key the List will change selection index.

I used LWUIT GUI builder to generate StateMachine/StateMachineBase class.

I've been trying to fix this all day. please help.


Solution

  • Pheromix's answer is correct but he didn't account for the UIBuilder. To override the Form creation in the UIBuilder override the method:

    protected Component createComponentInstance(String componentType, Class cls) {
        if(cls == com.sun.lwuit.Form.class) {
            return new MyFormSubclass();
        }
        return super.createComponentInstance(componentType, cls);
    }
    

    There is an option to override the Tab selection behavior but to get the most accurate behavior this might be the best approach.