Author: greg.ercolano
Date: 2013-03-23 00:55:09 -0700 (Sat, 23 Mar 2013)
New Revision: 9841
Log:
o Added tab_cell_nav() method to control Tab/Shift-Tab navigation of table
cells.
o Added move_cursor(R,C,shiftflag). Needed allow Shift-Tab not to create a
reverse selection.
Modified:
branches/branch-1.3/FL/Fl_Table.H
branches/branch-1.3/src/Fl_Table.cxx
Modified: branches/branch-1.3/FL/Fl_Table.H
===================================================================
--- branches/branch-1.3/FL/Fl_Table.H 2013-03-19 21:02:12 UTC (rev 9840)
+++ branches/branch-1.3/FL/Fl_Table.H 2013-03-23 07:55:09 UTC (rev 9841)
@@ -210,6 +210,12 @@
#if FLTK_ABI_VERSION >= 10301
int _scrollbar_size;
#endif
+#if FLTK_ABI_VERSION >= 10303
+ enum {
+ TABCELLNAV = 1<<0, ///> tab cell navigation flag
+ };
+ unsigned int flags_;
+#endif
// An STL-ish vector without templates
class FL_EXPORT IntVector {
@@ -823,6 +829,7 @@
int is_selected(int r, int c); // selected cell
void get_selection(int &row_top, int &col_left, int &row_bot, int
&col_right);
void set_selection(int row_top, int col_left, int row_bot, int col_right);
+ int move_cursor(int R, int C, int shiftselect);
int move_cursor(int R, int C);
/**
@@ -1107,6 +1114,36 @@
_scrollbar_size = newSize;
}
#endif
+#if FLTK_ABI_VERSION >= 10303
+ /**
+ Flag to control if Tab navigates table cells or not.
+
+ If on, Tab key navigates table cells.
+ If off, Tab key navigates fltk widget focus. (default)
+
+ As of fltk 1.3, the default behavior of the Tab key is to navigate focus
off
+ the current widget, and on to the next one. But in some applications,
+ it's useful for Tab to be used to navigate cells in the Fl_Table.
+
+ \param [in] val If \p val is 1, Tab key navigates cells in table, not fltk
widgets.<BR>
+ If \p val is 0, Tab key will advance focus to the next
fltk widget (default), and does not navigate cells in table.
+ */
+ void tab_cell_nav(int val) {
+ if ( val ) flags_ |= TABCELLNAV;
+ else flags_ &= ~TABCELLNAV;
+ }
+
+ /**
+ Get state of fltk widget tab navigation flag.
+
+ \returns 1 if Tab configured to navigate widget focus (default) or 0 for
Tab to navigate table cells.
+
+ \see tab_cell_nav(int)
+ */
+ int tab_cell_nav() const {
+ return(flags_ & TABCELLNAV ? 1 : 0);
+ }
+#endif
};
#endif /*_FL_TABLE_H*/
Modified: branches/branch-1.3/src/Fl_Table.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Table.cxx 2013-03-19 21:02:12 UTC (rev
9840)
+++ branches/branch-1.3/src/Fl_Table.cxx 2013-03-23 07:55:09 UTC (rev
9841)
@@ -131,6 +131,9 @@
#if FLTK_ABI_VERSION >= 10301
_scrollbar_size = 0;
#endif
+#if FLTK_ABI_VERSION >= 10303
+ flags_ = 0; // TABCELLNAV off
+#endif
box(FL_THIN_DOWN_FRAME);
vscrollbar = new Fl_Scrollbar(x()+w()-Fl::scrollbar_size(), y(),
@@ -674,7 +677,7 @@
redraw_range(R1, R2, C1, C2);
}
-int Fl_Table::move_cursor(int R, int C) {
+int Fl_Table::move_cursor(int R, int C, int shiftselect) {
if (select_row == -1) R++;
if (select_col == -1) C++;
R += select_row;
@@ -687,7 +690,7 @@
damage_zone(current_row, current_col, select_row, select_col, R, C);
select_row = R;
select_col = C;
- if (!Fl::event_state(FL_SHIFT)) {
+ if (!shiftselect || !Fl::event_state(FL_SHIFT)) {
current_row = R;
current_col = C;
}
@@ -696,7 +699,11 @@
return 1;
}
-// #define DEBUG 1
+int Fl_Table::move_cursor(int R, int C) {
+ return move_cursor(R,C,1);
+}
+
+//#define DEBUG 1
#ifdef DEBUG
#include <FL/names.h>
#define PRINTEVENT \
@@ -1020,10 +1027,13 @@
ret = move_cursor(1, 0);
break;
case FL_Tab:
+#if FLTK_ABI_VERSION >= 10303
+ if ( !tab_cell_nav() ) break; // not navigating cells? let fltk
handle it (STR#2862)
+#endif
if ( _event_state & FL_SHIFT ) {
- ret = move_cursor(0, -1); // shift-tab -> left
+ ret = move_cursor(0, -1, 0); // shift-tab -> left
} else {
- ret = move_cursor(0, 1); // tab -> right
+ ret = move_cursor(0, 1, 0); // tab -> right
}
break;
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit