Author: greg.ercolano Date: 2013-03-19 03:34:03 -0700 (Tue, 19 Mar 2013) New Revision: 9839 Log: Small fixes to keyboard navigation and 'current cell' coloring.
Modified: branches/branch-1.3/examples/table-spreadsheet.cxx Modified: branches/branch-1.3/examples/table-spreadsheet.cxx =================================================================== --- branches/branch-1.3/examples/table-spreadsheet.cxx 2013-03-18 20:00:04 UTC (rev 9838) +++ branches/branch-1.3/examples/table-spreadsheet.cxx 2013-03-19 10:34:03 UTC (rev 9839) @@ -52,10 +52,14 @@ input->callback(input_cb, (void*)this); input->when(FL_WHEN_ENTER_KEY_ALWAYS); // callback triggered when user hits Enter input->maximum_size(5); + input->color(FL_YELLOW); for (int c = 0; c < MAX_COLS; c++) for (int r = 0; r < MAX_ROWS; r++) values[r][c] = c + (r*MAX_COLS); // initialize cells end(); + row_edit = col_edit = 0; + select_row = current_row = 0; + select_col = current_col = 0; } ~Spreadsheet() { } @@ -156,7 +160,7 @@ } // Background if ( C < cols()-1 && R < rows()-1 ) { - fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, FL_WHITE); + fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, (R==row_edit && C==col_edit) ? FL_YELLOW : FL_WHITE); } else { fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, 0xbbddbb00); // money green } @@ -205,7 +209,11 @@ return; case FL_KEYBOARD: // key press in table? - if ( Fl::event_key() == FL_Escape ) exit(0); // ESC closes app + switch (Fl::event_key()) { + case FL_Escape: exit(0); // ESC closes app + case FL_Shift_L: return; // ignore shift + case FL_Shift_R: return; + } if (C == cols()-1 || R == rows()-1) return; // no editing of totals column done_editing(); // finish any previous editing start_editing(R,C); // start new edit @@ -229,6 +237,7 @@ } int main() { + Fl::option(Fl::OPTION_ARROW_FOCUS, 1); // we want arrow keys to navigate table's widgets Fl_Double_Window *win = new Fl_Double_Window(862, 322, "Fl_Table Spreadsheet"); Spreadsheet *table = new Spreadsheet(10, 10, win->w()-20, win->h()-20); // Table rows _______________________________________________ fltk-commit mailing list fltk-commit@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-commit