Various fixes:

o pre-selection of first cell
	o simplified input selection
	o Enabled ESC to quit app (original app did not handle it)
	o Ignore Fl_Tab to make tab navigation operate as expected



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7750 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Greg Ercolano 2010-10-26 10:58:42 +00:00
parent 0beca57ddf
commit 347007964e

View File

@ -248,8 +248,11 @@ void SingleInput::event_callback2() {
//FALLTHROUGH
case FL_KEYBOARD:
if (Fl::event() == FL_KEYBOARD && Fl::e_length == 0) {
return;
if ( Fl::event_key() == FL_Escape )
exit(0); // ESC closes app
if (Fl::event() == FL_KEYBOARD &&
( Fl::e_length == 0 || Fl::event_key() == FL_Tab) ) {
return; // ignore eg. keyboard nav keys
}
if (C == cols()-1 || R == rows()-1) return;
if (input->visible()) input->do_callback();
@ -262,8 +265,7 @@ void SingleInput::event_callback2() {
char s[30];
sprintf(s, "%d", values[R][C]);
input->value(s);
input->position(strlen(s)); // position cursor at end of string
input->mark(0); // pre-highlight (so typing replaces contents)
input->position(0,strlen(s)); // pre-highlight (so typing replaces contents)
input->show();
input->take_focus();
if (Fl::event() == FL_KEYBOARD && Fl::e_text[0] != '\r') {
@ -324,6 +326,7 @@ int main() {
table->col_resize(1);
table->cols(11);
table->col_width_all(70);
table->set_selection(0,0,0,0); // select top/left cell
// Add children to window
win.begin();