Change ObjectChoiceField Color not working on Blackberry OS 5.0

Posted by Ari R. Fikri on Stack Overflow See other posts from Stack Overflow or by Ari R. Fikri
Published on 2010-06-16T06:07:47Z Indexed on 2010/06/16 6:12 UTC
Read the original article Hit count: 581

Filed under:

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.

© Stack Overflow or respective owner

Related posts about blackberry