diff options
| author | Greg Ercolano <erco@seriss.com> | 2013-03-19 10:34:03 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2013-03-19 10:34:03 +0000 |
| commit | 9c6014f2d5246dd3c660d2826bf0b35db7131550 (patch) | |
| tree | cb838e910ffc2827b61aa24bb6a642bf6ea96817 /examples/table-spreadsheet.cxx | |
| parent | 684ad6910ba204ee86274bd8d15594322b60de41 (diff) | |
Small fixes to keyboard navigation and 'current cell' coloring.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9839 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'examples/table-spreadsheet.cxx')
| -rw-r--r-- | examples/table-spreadsheet.cxx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/examples/table-spreadsheet.cxx b/examples/table-spreadsheet.cxx index 9fef8935c..ddd361861 100644 --- a/examples/table-spreadsheet.cxx +++ b/examples/table-spreadsheet.cxx @@ -52,10 +52,14 @@ public: 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 @@ void Spreadsheet::draw_cell(TableContext context, int R,int C, int X,int Y,int W } // 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 @@ void Spreadsheet::event_callback2() { 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 @@ void Spreadsheet::event_callback2() { } 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 |
