Question

I have a manager that is handling the Touch click.

In order to have the Manager Focusable I have a Field that is acting as a Background and is focusable, This field change color when it is focused.

The problem is, I have multiple fields on this manager (which are not focusable), like LabelField, BitmapField, etc...

If the user click on one of non-focusable Field, it won't take into account the click on the Cell. But if the user clicks between 2 non-focusable fields (and then click on the Background Field), the click is took into account and works fine...

I would need some kind of click through set to true, how would I do that ?

P.S. : I do not want to put all Field focusable, because when using the trackball it would go through every Field, I just want the Whole Manager to be selected, not elements inside.

Was it helpful?

Solution

The Manager will actually get the click events - normally it will just pass them on. But you can process them if you want. The following code demonstrates the easiest way I find to make sure I process everything as I want. Try it on a touch screen and non touchscreen phone.

VerticalFieldManager testVFM = new VerticalFieldManager(Manager.USE_ALL_WIDTH) {
    protected boolean touchEvent(TouchEvent message) {
        int x = message.getX( 1 );
        int y = message.getY( 1 );
        if( x < 0 || y < 0 || x >= getExtent().width || y >= getExtent().height ) {
                // Outside the field
                return false;
        }
        if ( message.getEvent() == TouchEvent.UNCLICK ) {
            Status.show("Manager Clicked");
            return true;
        }
        return super.touchEvent(message);
    }
};
LabelField testlab = new LabelField("test", LabelField.FIELD_HCENTER);
testVFM.add(testlab);
LabelField testlab2 = new LabelField("test2", LabelField.FIELD_HCENTER);
testVFM.add(testlab2);
testVFM.add(new NullField() {
    protected boolean navigationClick(int status, int time){
        Status.show("NullField Clicked");
        return true;    
    }
}); // So Manager can get focus
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top