/** Moves focus to the last component in the previous row. */ protected void moveToPreviousRow() { if (Debug.ON) Logger.dev("OFocusManager.moveToPreviousRow CALLED "); int priorRank = focusedComponentIndex - 1; boolean moved = false; OFocusableComponent gainer = null; int firstRank = 0; if (priorRank >= firstRank) { // there is a previous component int currentY = focusedComponent.getY(); boolean keepLooking = true; for (; keepLooking && priorRank >= firstRank; priorRank--) { OComponent previousComponent = (OComponent) focusableComponents.elementAt(priorRank); if (previousComponent.getY() < currentY && previousComponent instanceof OFocusableComponent) { gainer = (OFocusableComponent) previousComponent; focusedComponentIndex = priorRank; keepLooking = false; moved = true; } } } if (moved) { moveFocus(gainer); } else // there is no prior row { OHandset.beep(); } if (Debug.ON) Logger.dev("OFocusManager.moveToPreviousRow EXITTING "); } // moveToPreviousRow
/** Moves focus to the first component in the next row. */ protected void moveToNextRow() { if (Debug.ON) Logger.dev("OFocusManager.moveToNextRow CALLED "); int nextRank = focusedComponentIndex + 1; boolean moved = false; OFocusableComponent gainer = null; int lastRank = focusableComponents.size() - 1; if (nextRank <= lastRank) { // there are more components int currentY = focusedComponent.getY(); boolean keepLooking = true; for (; keepLooking && nextRank <= lastRank; nextRank++) { OFocusableComponent nextComponent = (OFocusableComponent) focusableComponents.elementAt(nextRank); if (nextComponent.getY() > currentY) { // component is in a later row gainer = (OFocusableComponent) nextComponent; focusedComponentIndex = nextRank; keepLooking = false; moved = true; } } } if (moved) { moveFocus(gainer); } else // there is no next row { OHandset.beep(); } if (Debug.ON) Logger.dev("OFocusManager.moveToNextRow EXITTING "); } // moveToNextRow
/** * Processes a left key press. if the current component is not the first component in the * container then focus is passed to the component of rank 1 less than the current component */ protected void moveToPreviousField() { if (Debug.ON) Logger.dev("OFocusManager.processLeftKeyPress CALLED "); if (focusedComponentIndex > 0) { OFocusableComponent previousComponent = (OFocusableComponent) focusableComponents.elementAt(--focusedComponentIndex); moveFocus((OFocusableComponent) previousComponent); } else // first component, so merely beep { OHandset.beep(); } if (Debug.ON) Logger.dev("OFocusManager.processLeftKeyPress EXITTING "); } // moveToPreviousField
/** * Processes a right key press. if the current component is not the last component in the * container then focus is passed to the component of rank 1 greater than the current component. */ protected void moveToNextField() { if (Debug.ON) Logger.dev("OFocusManager.processRightKeyPRessed CALLED "); if (focusedComponentIndex < focusableComponents.size() - 1) { // not the last component, so find the next focusable component OFocusableComponent nextComponent = (OFocusableComponent) focusableComponents.elementAt(++focusedComponentIndex); moveFocus((OFocusableComponent) nextComponent); } else { // last focusable component, so merely beep OHandset.beep(); } if (Debug.ON) Logger.dev("OFocusManager.processRightKeyPress EXITTING "); } // moveToNextField