CustomItem ... i give up
Hi everyone
I am writing a component which represents a scrolled thin text line with icons on the sides. While pressing left right the item changes displayed text placed in the string table. I have problems with traverse ... the problem is taht when i place my component on form one above and one under it using left right iwant to change strings not loose the focus on the component. i tried this but still this is not working well
protected boolean traverse(int dir, int viewportWidth, int viewportHeight,
int[] visRect_inout) {
switch (dir) {
case Canvas.DOWN:
return false;
case Canvas.UP:
return false;
case Canvas.LEFT:
return true;
case Canvas.RIGHT:
return true;
}
return true;
}
Ok i finally solve it ...
The problem was the documentation. I couldn't find apropriate documentation for traversal method. Here it is
//On initial entry?br>//true indicates internal traversal accepted
//false indicates item doesn抰 accept internal traversal
// If traversal is already within the item?br>// true indicates traversal remains within the item
// false indicates traversal may exit the item
And the code that doeas it for me:
protected boolean traverse(int dir, int viewportWidth, int viewportHeight,
int[] visRect_inout) {
switch (dir) {
case Canvas.DOWN:
repaint();
if (!isInternalTraverse){
isInternalTraverse = true;
return true;
}else{
isInternalTraverse = false;
return false;
}
case Canvas.UP:
repaint();
if (!isInternalTraverse){
isInternalTraverse = true;
return true;
}else{
isInternalTraverse = false;
return false;
}
case Canvas.LEFT:
if (!isInternalTraverse){
isInternalTraverse = false;
return false;
}else{
activeItemIndex=activeItemIndex<=0?0:activeItemIndex-1;
isInternalTraverse = true;
updateAvailableCommands();
repaint();
return true;
}
case Canvas.RIGHT:
if (!isInternalTraverse){
isInternalTraverse = false;
return false;
}else{
activeItemIndex=(activeItemIndex>=itemNames.length-1)?itemNames.length-1:activeItemIndex+1;
isInternalTraverse = true;
updateAvailableCommands();
repaint();
return true;
}
}
return true;
}