08-18-2009 12:00 PM
The listfield semms to keep the last item selected when the focus leave the listfield... is there a way to show every item as unselected when the focus leave the listfield?
Solved! Go to Solution.
08-18-2009 01:00 PM
08-18-2009 01:06 PM - edited 08-18-2009 03:12 PM
Haven't seen that, thanks for your answer!
But i'm still not sure what to do with it ... i'm able to know if the focus is on the listfield or not but how can I remove the selection? Because even if the focus is on another field, the last item stay selected.
08-18-2009 05:41 PM - edited 08-19-2009 05:26 PM
In short what framework does when focus is moved (it not quite true but enough for this topic):
1) Setup Graphics object with default settings for non-focused field (including colors)
2) Pass graphics into the field that had focus for re-painting
3) Setup Graphics object with default settings for focused field (including colors)
4) Pass graphics into the field that recieves focus for painting of focused area
If you need just properly paint focus you can change your condition
if(listField.getSelectedIndex() == index)
in drawListRow method to
Important thing here is what happens at step 2 when control is asked to re-paint itself to clear focus. Last row is painted as focused because your condition is true for the last row when control.
My idea is simple: if you want you want to customize style for focus - do it only when focus area is being painted rather than every time control is repainted. And framework will do everything else for you.
Edit: some typos in description including significant one in description of step 3
08-19-2009 01:12 AM
When focus is not on listfield ,then set the selectedIndex to -1. May be this will help you in solving your issue.
Also look at this thread
08-19-2009 05:22 AM - edited 08-19-2009 05:23 AM
08-19-2009 10:54 AM
Rajat : Like SergGr said , setting the selectedindex to -1 only pout the focus on the first row.
Thanks SerGr! Now it works fine and I can understand how the listfield really works!
I appreciate that you give all these explanation instead of only giving some working parts of code, wich is not that bad tho
08-20-2009 12:47 AM
Thanks both for updating me on that .