summaryrefslogtreecommitdiff
path: root/examples/table-spreadsheet.cxx
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2020-07-13 09:47:26 -0700
committerGreg Ercolano <erco@seriss.com>2020-07-13 09:47:26 -0700
commit44375763aabefb9c3403540e2914aa41aed17a87 (patch)
tree4db2abd7fc3b45fe5a364c94511741669b9a2b4b /examples/table-spreadsheet.cxx
parent9925b0f12852dc37fb7fb773a525486c258d2c62 (diff)
A few extra comments for table-spreadsheet.
Also small but unnecessary code change to reset row_edit/col to zero after editing for example clarity. Unnecessary b/c those vars are ignored anyway when input visibility turned off, so change is more cosmetic codewise.
Diffstat (limited to 'examples/table-spreadsheet.cxx')
-rw-r--r--examples/table-spreadsheet.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/table-spreadsheet.cxx b/examples/table-spreadsheet.cxx
index e276a80d4..94a41124d 100644
--- a/examples/table-spreadsheet.cxx
+++ b/examples/table-spreadsheet.cxx
@@ -46,11 +46,11 @@ public:
when(FL_WHEN_NOT_CHANGED|when());
// Create input widget that we'll use whenever user clicks on a cell
input = new Fl_Int_Input(W/2,H/2,0,0);
- input->hide();
+ input->hide(); // hide until needed
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);
+ input->color(FL_YELLOW); // yellow to standout during editing
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
@@ -81,12 +81,14 @@ public:
input->value(s);
input->position(0,strlen(s)); // Select entire input field
input->show(); // Show the input widget, now that we've positioned it
- input->take_focus();
+ input->take_focus(); // Put keyboard focus into the input widget
}
// Tell the input widget it's done editing, and to 'hide'
void done_editing() {
if (input->visible()) { // input widget visible, ie. edit in progress?
set_value_hide(); // Transfer its current contents to cell and hide
+ row_edit = 0; // Disable these until needed again
+ col_edit = 0;
}
}
// Return the sum of all rows in this column