- @Override
- public void onKeypress(final TKeypressEvent keypress) {
- if (keypress.equals(kbLeft)) {
- hScroller.decrement();
- } else if (keypress.equals(kbRight)) {
- hScroller.increment();
- } else if (keypress.equals(kbUp)) {
- if (files.size() > 0) {
- if (selectedFile >= 0) {
- if (selectedFile > 0) {
- selectedFile--;
- }
- } else {
- selectedFile = files.size() - 1;
- }
- path = files.get(selectedFile);
- }
- } else if (keypress.equals(kbDown)) {
- if (files.size() > 0) {
- if (selectedFile >= 0) {
- if (selectedFile < files.size() - 1) {
- selectedFile++;
- }
- } else {
- selectedFile = 0;
- }
- path = files.get(selectedFile);
- }
- } else if (keypress.equals(kbPgUp)) {
- vScroller.bigDecrement();
- } else if (keypress.equals(kbPgDn)) {
- vScroller.bigIncrement();
- } else if (keypress.equals(kbHome)) {
- vScroller.toTop();
- if (files.size() > 0) {
- selectedFile = 0;
- path = files.get(selectedFile);
- }
- } else if (keypress.equals(kbEnd)) {
- vScroller.toBottom();
- if (files.size() > 0) {
- selectedFile = files.size() - 1;
- path = files.get(selectedFile);
- }
- } else if (keypress.equals(kbTab)) {
- getParent().switchWidget(true);
- } else if (keypress.equals(kbShiftTab) || keypress.equals(kbBackTab)) {
- getParent().switchWidget(false);
- } else if (keypress.equals(kbEnter)) {
- if (selectedFile >= 0) {
- path = files.get(selectedFile);
- dispatch();
- }
- } else {
- // Pass other keys (tab etc.) on
- super.onKeypress(keypress);