int i = this.focusedIndex + steps; if (i > this.items.length) { i = this.items.length - 2; } if (i < 0) { i = 1; }
int i = this.focusedIndex; if (steps != 0) {  int doneSteps = 0; steps = Math.abs( steps ) + 1; Item item = this.items[i]; while( doneSteps <= steps) { doneSteps += item.colSpan; if (doneSteps >= steps) {  break; } if (forwardFocus) { i++; if (i == this.items.length - 1 ) { i = this.items.length - 2; break; } else if (i == this.items.length) { i = this.items.length - 1; break; } } else { i--; if (i < 0) { i = 1; break; } } item = this.items[i]; System.out.println("focusedIndex=" + this.focusedIndex + ", startIndex=" + i + ", steps=" + steps + ", doneSteps=" + doneSteps); } if (doneSteps >= steps && item.colSpan != 1) { if (forwardFocus) { i--; if (i < 0) { i = this.items.length - 1; } System.out.println("forward: Adjusting startIndex to " + i ); } else { i = (i + 1) % this.items.length; System.out.println("backward: Adjusting startIndex to " + i ); } } }   if (i > this.items.length) { i = this.items.length - 2; } if (i < 0) { i = 1; }
	private boolean shiftFocus(boolean forwardFocus, int steps ) {		if ( this.items == null ) {			return false;		}		int i = this.focusedIndex + steps;		if (i > this.items.length) {			i = this.items.length - 2;		}		if (i < 0) {			i = 1;		}		Item item = null;		//#if polish.Container.allowCycling != false			boolean allowCycle = this.enableScrolling && this.allowCycling;			if (allowCycle) {				//#if polish.css.scroll-mode					if (!this.scrollSmooth) {						if (forwardFocus) {							// when you scroll to the bottom and							// there is still space, do							// scroll first before cycling to the							// first item:							allowCycle = (this.yOffset + this.itemHeight <= this.yBottom);						} else {							// when you scroll to the top and							// there is still space, do							// scroll first before cycling to the							// last item:							allowCycle = (this.yOffset == 0);						}											} else {				//#endif					if (forwardFocus) {						// when you scroll to the bottom and						// there is still space, do						// scroll first before cycling to the						// first item:						allowCycle = (this.targetYOffset + this.itemHeight <= this.yBottom);					} else {						// when you scroll to the top and						// there is still space, do						// scroll first before cycling to the						// last item:						allowCycle = (this.targetYOffset == 0);					}				//#if polish.css.scroll-mode					}				//#endif				//#debug				System.out.println("shiftFocus: allowCycl=" + allowCycle + ", isFoward=" + forwardFocus + ", targetYOffset=" + this.targetYOffset + ", yOffset=" + this.yOffset );				}		//#endif		while (true) {			if (forwardFocus) {				i++;				if (i >= this.items.length) {					//#if polish.Container.allowCycling != false						if (allowCycle) {							allowCycle = false;							i = 0;						} else {							break;						}					//#else						break;					//#endif				}			} else {				i--;				if (i < 0) {					//#if polish.Container.allowCycling != false						if (allowCycle) {							allowCycle = false;							i = this.items.length - 1;						} else {							break;						}					//#else						break;					//#endif				}			}			item = this.items[i];			if (item.appearanceMode != Item.PLAIN) {				break;			}		}		if (item == null || item.appearanceMode == Item.PLAIN || item == this.focusedItem) {			return false;		}		int direction = Canvas.UP;		if (forwardFocus) {			direction = Canvas.DOWN;		}		focus(i, item, direction );		return true;	}