Home/End support in menus; in textboxes support Ctrl-a/e/u but ignore PgUp/PgDn

This commit is contained in:
András Salamon 2005-04-20 17:27:39 +00:00
parent 4de057a1ef
commit 95f9e95618
3 changed files with 18 additions and 4 deletions

View file

@ -43,7 +43,8 @@ CVS HEAD:
* fixed bug #12611: modifying villages with [terrain] interacting badly with capturing them.
* fixed user-campaigns not being translatable anymore
* fixed the formatting of wrapped text lines being lost
* added support for Home/End in menus, ctrl-a/e/u in textboxes
Version 0.9.0:
* user interface improvements:
* added alternative theme: DFool

View file

@ -235,6 +235,12 @@ void menu::key_press(SDLKey key)
case SDLK_PAGEDOWN:
move_selection_down(max_items_onscreen());
break;
case SDLK_HOME:
move_selection(0);
break;
case SDLK_END:
move_selection(items_.size() - 1);
break;
//case SDLK_RETURN:
// double_clicked_ = true;
// break;

View file

@ -421,10 +421,10 @@ void textbox::handle_event(const SDL_Event& event)
if(c == SDLK_RIGHT && cursor_ < text_.size())
++cursor_;
if(c == SDLK_END)
if(c == SDLK_END || (c == SDLK_e && (modifiers & KMOD_CTRL)))
cursor_ = text_.size();
if(c == SDLK_HOME)
if(c == SDLK_HOME || (c == SDLK_a && (modifiers & KMOD_CTRL)))
cursor_ = 0;
if((old_cursor != cursor_) && (modifiers & KMOD_SHIFT)) {
@ -443,6 +443,12 @@ void textbox::handle_event(const SDL_Event& event)
}
}
if(c == SDLK_u && (modifiers & KMOD_CTRL)) {
changed = true;
cursor_ = 0;
text_.resize(0);
}
if(c == SDLK_DELETE && !text_.empty()) {
changed = true;
if(is_selection()) {
@ -461,7 +467,8 @@ void textbox::handle_event(const SDL_Event& event)
//movement characters may have a "Unicode" field on some platforms, so ignore it.
if(!(c == SDLK_UP || c == SDLK_DOWN || c == SDLK_LEFT || c == SDLK_RIGHT ||
c == SDLK_DELETE || c == SDLK_BACKSPACE || c == SDLK_END || c == SDLK_HOME)) {
c == SDLK_DELETE || c == SDLK_BACKSPACE || c == SDLK_END || c == SDLK_HOME ||
c == SDLK_PAGEUP || c == SDLK_PAGEDOWN)) {
if(character != 0)
LOG_STREAM(info, display) << "Char: " << character << ", c = " << c << "\n";