summaryrefslogtreecommitdiff
path: root/examples/table-with-keyboard-nav.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'examples/table-with-keyboard-nav.cxx')
-rw-r--r--examples/table-with-keyboard-nav.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/table-with-keyboard-nav.cxx b/examples/table-with-keyboard-nav.cxx
index 855619e7b..f101a71de 100644
--- a/examples/table-with-keyboard-nav.cxx
+++ b/examples/table-with-keyboard-nav.cxx
@@ -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();