(int keyCode)
| 926 | |
| 927 | /// {@inheritDoc} |
| 928 | @Override |
| 929 | public void keyPressed(int keyCode) { |
| 930 | // scrolling events are in keyPressed to provide immediate feedback |
| 931 | if (!handlesInput()) { |
| 932 | return; |
| 933 | } |
| 934 | |
| 935 | int gameAction = Display.getInstance().getGameAction(keyCode); |
| 936 | int keyFwd; |
| 937 | int keyBck; |
| 938 | if (getOrientation() != HORIZONTAL) { |
| 939 | keyFwd = Display.GAME_DOWN; |
| 940 | keyBck = Display.GAME_UP; |
| 941 | if (gameAction == Display.GAME_LEFT || gameAction == Display.GAME_RIGHT) { |
| 942 | setHandlesInput(false); |
| 943 | } |
| 944 | } else { |
| 945 | if (isRTL()) { |
| 946 | keyFwd = Display.GAME_LEFT; |
| 947 | keyBck = Display.GAME_RIGHT; |
| 948 | } else { |
| 949 | keyFwd = Display.GAME_RIGHT; |
| 950 | keyBck = Display.GAME_LEFT; |
| 951 | } |
| 952 | if (gameAction == Display.GAME_DOWN || gameAction == Display.GAME_UP) { |
| 953 | setHandlesInput(false); |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | int selectedIndex = model.getSelectedIndex(); |
| 958 | if (gameAction == keyBck) { |
| 959 | selectedIndex--; |
| 960 | if (selectedIndex < 0) { |
| 961 | if (fixedSelection != FIXED_NONE && fixedSelection != FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE) { |
| 962 | selectedIndex = size() - 1; |
| 963 | } else { |
| 964 | selectedIndex = 0; |
| 965 | setHandlesInput(false); |
| 966 | } |
| 967 | } |
| 968 | } else if (gameAction == keyFwd) { |
| 969 | selectedIndex++; |
| 970 | if (selectedIndex >= size()) { |
| 971 | if (fixedSelection != FIXED_NONE && fixedSelection != FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE) { |
| 972 | selectedIndex = 0; |
| 973 | } else { |
| 974 | selectedIndex = size() - 1; |
| 975 | setHandlesInput(false); |
| 976 | } |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | if (selectedIndex != model.getSelectedIndex()) { |
| 981 | model.setSelectedIndex(selectedIndex); |
| 982 | int direction = (gameAction == keyFwd ? 1 : -1); |
| 983 | if ((isRTL()) && (getOrientation() == HORIZONTAL)) { |
| 984 | direction = -direction; |
| 985 | } |
nothing calls this directly
no test coverage detected