tags:

views:

131

answers:

0

I want to create a custom ObjectChoiceField, the expected behavior is if the data change then upon leavinge the focus the font color will change. I have succeded in BB OS upto 4.7 but when tested on simulator and on real device with BB OS 5.0 the color won't change. This is my class :

public class MyObjectChoiceField extends ObjectChoiceField {
int color;
Object oldValue, newValue;
boolean isChanged;

public MyObjectChoiceField(){
    super();
    oldValue = new Object();
    newValue = new Object();
}

public MyObjectChoiceField(int color, String label, String[] choices, int intP, long styleP){
    super(label, choices, intP, styleP);
    this.color = color;
}

public void onUnfocus(){
    if (getSelectedIndex() != -1){
        newValue = getChoice(getSelectedIndex());       
        if (oldValue != newValue){
            isChanged = true;
            invalidate();
        }           
    }
    super.onUnfocus();
}

public void onFocus(int directionInt){
    if (getSelectedIndex() != -1)
        oldValue = getChoice(getSelectedIndex());           
    super.onFocus(directionInt);
}

public void paint(Graphics g){
    if (isChanged){ 
        g.setColor(this.color);
    }           
    super.paint(g);
}

What should I do to make this also work on BB OS 5.0. FYI : The ObjectChoiceField in BB 5.0 is look like a button with a triangle point down in the right side, which is different with BB OS 4.7.