On 03/30/12 05:31, Ian MacArthur wrote:
> I'd (fancifully!) imagined it might be like the Fl_Browser,
> so that of browser worked then table should too...
I don't think I ever got around to adding full keyboard
navigation to Fl_Table.
There is the concept of a 'cursor' in the form of
'current_row' and 'current_col' variables, and this
cursor can be moved around with the arrow keys.
Since the app handles all cell drawing, the app has to
handle drawing this cursor if it wants it to be visible.
Thing is, I don't think any of our test programs show
how to do that; guess I'll add it to one of the examples,
or make a new one.
Basically, in the app's draw_cell() callback, when
CELL_CONTEXT is received (which tells the app to draw a cell),
one can check to see if the row/col values of that cell match
the cursor's row/col values, and if so, draw the focus_box(), eg:
---- snip
// Handle drawing all cells in table
void MyTable::draw_cell(TableContext context, int R, int C, int X, int Y, int
W, int H) {
[..]
case CONTEXT_CELL: {
[..cell drawing here..]
if ( R == current_row && C == current_col ) // ADD THIS
draw_focus(box(),X,Y,W,H); // ADD THIS
fl_pop_clip();
return;
}
---- snip
As a test, I just added that to the table-sort.cxx example
and it shows the little focus box when you use the arrow keys
to move around, and the table scrolls when the cursor moves
off an edge, etc.
In the above case, it draws the focus box around just the cell,
but you can also draw it over the whole row if you want by
ignoring the current_col value, and using the entire width
of the screen instead of the X and W values.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk