diff --git a/include/colors.h b/include/colors.h index df5859555..07a953e36 100755 --- a/include/colors.h +++ b/include/colors.h @@ -37,6 +37,7 @@ extern bool AUTOEND; extern int TOOL_SIZE; extern bool TOOL_TEXT; extern bool EASY_RIDER; +extern bool ENTER_AS_TAB; const COLOR COLOR_DKCYAN = XVT_MAKE_COLOR(0,128,128); const COLOR COLOR_DKYELLOW = XVT_MAKE_COLOR(128,128, 0); diff --git a/include/controls.cpp b/include/controls.cpp index a4af9b117..8273a1ae4 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -44,6 +44,7 @@ bool NATIVE_CONTROLS = false; int TOOL_SIZE = 24; bool TOOL_TEXT = false; bool EASY_RIDER = true; +bool ENTER_AS_TAB = false; HIDDEN bool _button_blocked = false; HIDDEN int _last_mouse_button = 0; @@ -361,6 +362,7 @@ void customize_colors() EASY_RIDER_COLOR = blend_colors(NORMAL_BACK_COLOR, DISABLED_BACK_COLOR, 0.5); NATIVE_CONTROLS = ADVANCED_GRAPHICS && colors.get_bool("NativeControls", NULL, -1, NATIVE_CONTROLS); xi_set_pref(XI_PREF_NATIVE_CTRLS, NATIVE_CONTROLS); + ENTER_AS_TAB = colors.get_bool("EnterAsTab", NULL, -1, ENTER_AS_TAB); TOOL_SIZE = colors.get_int("ToolSize", NULL, -1, TOOL_SIZE); TOOL_TEXT = colors.get_bool("ToolText", NULL, -1, TOOL_TEXT); diff --git a/include/msksheet.cpp b/include/msksheet.cpp index 2af8d53ef..13b577da0 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -1730,19 +1730,32 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev) case K_ENTER: case K_SHIFT+K_ENTER: { - const int next_rec = find_enabled_record(_cur_rec, k == K_ENTER ? +1 : -1); - if (next_rec >= 0) + const int dir = k == K_ENTER ? +1 : -1; + if (ENTER_AS_TAB) { - dispatch_e_char(parent(), K_TAB); - dispatch_e_char(parent(), k == K_ENTER ? K_DOWN : K_UP); - refused = TRUE; + const int next_col = find_enabled_column(_cur_rec, _cur_col+dir, dir); + if (next_col != 0 && next_col != _cur_col && ((next_col>_cur_col)^(dir < 0))) + { + dispatch_e_char(parent(), k == K_ENTER ? K_TAB : K_BTAB); + refused = TRUE; + } } - else + if (!refused) { - dispatch_e_char(parent(), k == K_ENTER ? K_F3 : K_F4); - refused = TRUE; + const int next_rec = find_enabled_record(_cur_rec, dir); + if (next_rec >= 0) + { + dispatch_e_char(parent(), K_TAB); + dispatch_e_char(parent(), k == K_ENTER ? K_DOWN : K_UP); + refused = TRUE; + } + else + { + dispatch_e_char(parent(), k == K_ENTER ? K_F3 : K_F4); + refused = TRUE; + } } - } + } break; case K_ESC: if (xi_move_focus(get_interface()))