diff options
Diffstat (limited to 'gui/widgets')
-rw-r--r-- | gui/widgets/editable.cpp | 102 | ||||
-rw-r--r-- | gui/widgets/editable.h | 3 | ||||
-rw-r--r-- | gui/widgets/edittext.cpp | 3 | ||||
-rw-r--r-- | gui/widgets/edittext.h | 3 | ||||
-rw-r--r-- | gui/widgets/list.cpp | 4 | ||||
-rw-r--r-- | gui/widgets/list.h | 3 | ||||
-rw-r--r-- | gui/widgets/popup.cpp | 3 | ||||
-rw-r--r-- | gui/widgets/popup.h | 3 | ||||
-rw-r--r-- | gui/widgets/scrollbar.cpp | 3 | ||||
-rw-r--r-- | gui/widgets/scrollbar.h | 3 | ||||
-rw-r--r-- | gui/widgets/tab.cpp | 3 | ||||
-rw-r--r-- | gui/widgets/tab.h | 3 |
12 files changed, 59 insertions, 77 deletions
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp index 2ee3575bc6..4a0ee54828 100644 --- a/gui/widgets/editable.cpp +++ b/gui/widgets/editable.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/rect.h" @@ -96,6 +93,28 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) { if (_caretVisible) drawCaret(true); + // Remap numeric keypad if NUM lock is *not* active. + // This code relies on the fact that the various KEYCODE_KP* values are + // consecutive. + if (0 == (state.flags & Common::KBD_NUM) + && Common::KEYCODE_KP0 <= state.keycode + && state.keycode <= Common::KEYCODE_KP_PERIOD) { + const Common::KeyCode remap[11] = { + Common::KEYCODE_INSERT, // KEYCODE_KP0 + Common::KEYCODE_END, // KEYCODE_KP1 + Common::KEYCODE_DOWN, // KEYCODE_KP2 + Common::KEYCODE_PAGEDOWN, // KEYCODE_KP3 + Common::KEYCODE_LEFT, // KEYCODE_KP4 + Common::KEYCODE_INVALID, // KEYCODE_KP5 + Common::KEYCODE_RIGHT, // KEYCODE_KP6 + Common::KEYCODE_HOME, // KEYCODE_KP7 + Common::KEYCODE_UP, // KEYCODE_KP8 + Common::KEYCODE_PAGEUP, // KEYCODE_KP9 + Common::KEYCODE_DELETE, // KEYCODE_KP_PERIOD + }; + state.keycode = remap[state.keycode - Common::KEYCODE_KP0]; + } + switch (state.keycode) { case Common::KEYCODE_RETURN: case Common::KEYCODE_KP_ENTER: @@ -120,27 +139,6 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) { forcecaret = true; break; - // Keypad & special keys - // - if num lock is set, we always go to the default case - // - if num lock is not set, we either fall down to the special key case - // or ignore the key press in case of 0 (INSERT), 2 (DOWN), 3 (PGDWN) - // 5, 8 (UP) and 9 (PGUP) - - case Common::KEYCODE_KP0: - case Common::KEYCODE_KP2: - case Common::KEYCODE_KP3: - case Common::KEYCODE_KP5: - case Common::KEYCODE_KP8: - case Common::KEYCODE_KP9: - if (state.flags & Common::KBD_NUM) - defaultKeyDownHandler(state, dirty, forcecaret, handled); - break; - - case Common::KEYCODE_KP_PERIOD: - if (state.flags & Common::KBD_NUM) { - defaultKeyDownHandler(state, dirty, forcecaret, handled); - break; - } case Common::KEYCODE_DELETE: if (_caretPos < (int)_editString.size()) { _editString.deleteChar(_caretPos); @@ -151,22 +149,15 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) { forcecaret = true; break; - case Common::KEYCODE_KP1: - if (state.flags & Common::KBD_NUM) { - defaultKeyDownHandler(state, dirty, forcecaret, handled); - break; - } + case Common::KEYCODE_DOWN: case Common::KEYCODE_END: + // Move caret to end dirty = setCaretPos(_editString.size()); forcecaret = true; break; - case Common::KEYCODE_KP4: - if (state.flags & Common::KBD_NUM) { - defaultKeyDownHandler(state, dirty, forcecaret, handled); - break; - } case Common::KEYCODE_LEFT: + // Move caret one left (if possible) if (_caretPos > 0) { dirty = setCaretPos(_caretPos - 1); } @@ -174,12 +165,8 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) { dirty = true; break; - case Common::KEYCODE_KP6: - if (state.flags & Common::KBD_NUM) { - defaultKeyDownHandler(state, dirty, forcecaret, handled); - break; - } case Common::KEYCODE_RIGHT: + // Move caret one right (if possible) if (_caretPos < (int)_editString.size()) { dirty = setCaretPos(_caretPos + 1); } @@ -187,16 +174,43 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) { dirty = true; break; - case Common::KEYCODE_KP7: - if (state.flags & Common::KBD_NUM) { - defaultKeyDownHandler(state, dirty, forcecaret, handled); - break; - } + case Common::KEYCODE_UP: case Common::KEYCODE_HOME: + // Move caret to start dirty = setCaretPos(0); forcecaret = true; break; +#ifdef MACOSX + // Let ctrl-a / ctrl-e move the caret to the start / end of the line. + // + // These shortcuts go back a long time for command line programs. As + // for edit fields in GUIs, they are supported natively on Mac OS X, + // which is why I enabled these shortcuts there. + // On other systems (Windows, Gnome), Ctrl-A by default means + // "select all", which is why I didn't enable the shortcuts there + // for now, to avoid potential confusion. + // + // But since we don't support text selection, and since at least Gnome + // can be configured to also support ctrl-a and ctrl-e, we may want + // to extend this code to other targets, maybe even all. I'll leave + // this to other porters to decide, though. + case Common::KEYCODE_a: + case Common::KEYCODE_e: + if (state.flags & Common::KBD_CTRL) { + if (state.keycode == Common::KEYCODE_a) { + // Move caret to start + dirty = setCaretPos(0); + forcecaret = true; + } else if (state.keycode == Common::KEYCODE_e) { + // Move caret to end + dirty = setCaretPos(_editString.size()); + forcecaret = true; + } + break; + } +#endif + default: defaultKeyDownHandler(state, dirty, forcecaret, handled); } diff --git a/gui/widgets/editable.h b/gui/widgets/editable.h index e0b6375919..4b51ac9145 100644 --- a/gui/widgets/editable.h +++ b/gui/widgets/editable.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef GUI_WIDGETS_EDITABLE_H diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp index 106262bafe..d4a4407ee0 100644 --- a/gui/widgets/edittext.cpp +++ b/gui/widgets/edittext.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "gui/widgets/edittext.h" diff --git a/gui/widgets/edittext.h b/gui/widgets/edittext.h index b94e58780c..a34dc4b5dd 100644 --- a/gui/widgets/edittext.h +++ b/gui/widgets/edittext.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef GUI_WIDGETS_EDITTEXT_H diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp index 1f7846c503..065b240471 100644 --- a/gui/widgets/list.cpp +++ b/gui/widgets/list.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/system.h" @@ -590,6 +587,7 @@ void ListWidget::startEditMode() { if (_editable && !_editMode && _selectedItem >= 0) { _editMode = true; setEditString(_list[_selectedItem]); + _caretPos = _editString.size(); // Force caret to the *end* of the selection. if (_listColors.empty()) { _editColor = ThemeEngine::kFontColorNormal; } else { diff --git a/gui/widgets/list.h b/gui/widgets/list.h index 4bc9adc5ef..41fae37a71 100644 --- a/gui/widgets/list.h +++ b/gui/widgets/list.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef GUI_WIDGETS_LIST_H diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp index cab556065f..1a552e97c0 100644 --- a/gui/widgets/popup.cpp +++ b/gui/widgets/popup.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/system.h" diff --git a/gui/widgets/popup.h b/gui/widgets/popup.h index b3b3e30837..34983adbeb 100644 --- a/gui/widgets/popup.h +++ b/gui/widgets/popup.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef GUI_WIDGETS_POPUP_H diff --git a/gui/widgets/scrollbar.cpp b/gui/widgets/scrollbar.cpp index 38383c0e55..cc8e587668 100644 --- a/gui/widgets/scrollbar.cpp +++ b/gui/widgets/scrollbar.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/rect.h" diff --git a/gui/widgets/scrollbar.h b/gui/widgets/scrollbar.h index 53a3369fb4..3b248ce8a4 100644 --- a/gui/widgets/scrollbar.h +++ b/gui/widgets/scrollbar.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef GUI_WIDGETS_SCROLLBAR_H diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index 721fb88cf8..66f33907ca 100644 --- a/gui/widgets/tab.cpp +++ b/gui/widgets/tab.cpp @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #include "common/util.h" diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h index aec68cca0a..b19036979e 100644 --- a/gui/widgets/tab.h +++ b/gui/widgets/tab.h @@ -17,9 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ */ #ifndef GUI_WIDGETS_TAB_H |