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.
This commit is contained in:
parent
9925b0f128
commit
44375763aa
@ -46,11 +46,11 @@ public:
|
|||||||
when(FL_WHEN_NOT_CHANGED|when());
|
when(FL_WHEN_NOT_CHANGED|when());
|
||||||
// Create input widget that we'll use whenever user clicks on a cell
|
// 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 = new Fl_Int_Input(W/2,H/2,0,0);
|
||||||
input->hide();
|
input->hide(); // hide until needed
|
||||||
input->callback(input_cb, (void*)this);
|
input->callback(input_cb, (void*)this);
|
||||||
input->when(FL_WHEN_ENTER_KEY_ALWAYS); // callback triggered when user hits Enter
|
input->when(FL_WHEN_ENTER_KEY_ALWAYS); // callback triggered when user hits Enter
|
||||||
input->maximum_size(5);
|
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 c = 0; c < MAX_COLS; c++)
|
||||||
for (int r = 0; r < MAX_ROWS; r++)
|
for (int r = 0; r < MAX_ROWS; r++)
|
||||||
values[r][c] = c + (r*MAX_COLS); // initialize cells
|
values[r][c] = c + (r*MAX_COLS); // initialize cells
|
||||||
@ -81,12 +81,14 @@ public:
|
|||||||
input->value(s);
|
input->value(s);
|
||||||
input->position(0,strlen(s)); // Select entire input field
|
input->position(0,strlen(s)); // Select entire input field
|
||||||
input->show(); // Show the input widget, now that we've positioned it
|
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'
|
// Tell the input widget it's done editing, and to 'hide'
|
||||||
void done_editing() {
|
void done_editing() {
|
||||||
if (input->visible()) { // input widget visible, ie. edit in progress?
|
if (input->visible()) { // input widget visible, ie. edit in progress?
|
||||||
set_value_hide(); // Transfer its current contents to cell and hide
|
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
|
// Return the sum of all rows in this column
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user