Reputation: 197
How to draw focus to a VerticalFieldManager
in BlackBerry.
I have tried this but not working.
VerticalFieldManager vv=new VerticalFieldManager(Manager.focusFOCUSABLE);
Upvotes: 0
Views: 758
Reputation: 1362
this is the way to do it:
VerticalFieldManager vv=new VerticalFieldManager(FOCUSABLE) {
protected void paintBackground(Graphics g) {
int prevColor = g.getColor();
int bgColor;
if (isFocus()) {
bgColor = Color.Blue;
} else {
bgColor = Color.White;
}
g.setColor(bgColor);
g.fillRoundRect(0, 0, getPreferredWidth(), getPreferredHeight(), 0, 0);
g.setColor(prevColor);
}
public void onFocus(int direction) {
super.onFocus(direction);
this.invalidate();
}
public void onUnfocus() {
super.onUnfocus();
this.invalidate();
}
};
_focusAnchor = new NullField(FOCUSABLE);
add(_focusAnchor);
Upvotes: 0
Reputation: 28168
You can try calling Field.setFocus
on it, but since a manager is a container, I'm not sure you are going to see "the focus" over it.
If it doesn't work, you can try also overriding the paint
method and draw your own custom focus when isFocus
returns true.
Upvotes: 1
Reputation: 4158
try this -
VerticalFieldManager vv=new VerticalFieldManager(FOCUSABLE);
then add items to the vv.
Upvotes: 0