Hi Greg & Co., this is a lengthy message, so I apologize in advance....
I played with the sample box code you gave me and it worked fine for your
examples... so I went back to my original code and delved deeper by printing to
stdout all the events in all the handlers I had.
I got the FL_KEYDOWN pressed highlighting working (finally!) such that holding
the up/down key will consecutively move up and down the highlited row so long
as the key remains pressed.
The kicker is that Fl_Table has to have focus (and for the current way my
program is setup this can only be achieved by first clicking within the table
with the mouse). If I am in an Fl_Input (created external from the table - as
my table does not implement Fl_Inputs like your examples), and press up/down
arrow key, I have discovered that Fl_Window (that has the Fl_Input box) and
consequently Fl_Table never receives the events (discovered thanks to the
printf you gave me below!).
So I looked at Fl_Input.cxx's handle function, it appears it should pass my
up/down key presses for other widgets to handle.... I think? Not really
familiar with the inner workings of FLTK. It DOES seem to pass FL_KEYUP, but
NOT FL_KEYDOWN (see my provided sample program further down).
This is from version 1.3.x-r8518, compiled on Windows:
*** Relevant Excerpts from Fl_Input.cxx ***
case FL_Up:
#ifdef __APPLE__
if (mods==0) return kf_lines_up(1); // Up
(OSX-HIG)
if (mods==FL_CTRL) return kf_page_up(); // Ctrl-Up
(TE !HIG)
if (mods==FL_ALT) return kf_move_up_and_sol(); // Alt-Up
(OSX-HIG)
if (mods==FL_META) return kf_top(); // Meta-Up
(OSX-HIG)
return 0; // ignore other
combos, pass to parent
#else
if (mods==0) return kf_lines_up(1); // Up
(WP,NP,WOW,GE,KE,OF)
if (mods==FL_CTRL) return kf_move_up_and_sol(); // Ctrl-Up
(WP,!NP,WOW,GE,!KE,OF)
return 0; // ignore other
combos, pass to parent
#endif
case FL_Down:
#ifdef __APPLE__
if (mods==0) return kf_lines_down(1); // Dn
(OSX-HIG)
if (mods==FL_CTRL) return kf_page_down(); // Ctrl-Dn
(TE !HIG)
if (mods==FL_ALT) return kf_move_down_and_eol(); // Alt-Dn
(OSX-HIG)
if (mods==FL_META) return kf_bottom(); // Meta-Dn
(OSX-HIG)
return 0; // ignore other
combos, pass to parent
#else
if (mods==0) return kf_lines_down(1); // Dn
(WP,NP,WOW,GE,KE,OF)
if (mods==FL_CTRL) return kf_move_down_and_eol(); // Ctrl-Down
(WP,!NP,WOW,GE,!KE,OF)
return 0; // ignore other
combos, pass to parent
#endif
case FL_KEYBOARD:
if (Fl::event_key() == FL_Tab // Tab key?
&& !Fl::event_state(FL_SHIFT) // no shift?
&& !tab_nav() // with tab navigation
disabled?
&& input_type() == FL_MULTILINE_INPUT // with a multiline
input?
&& (mark()==0 && position()==size())) { // while entire field
selected?
// Set cursor to the end of the selection...
if (mark() > position())
position(mark());
else
position(position());
return (1);
} else {
if (active_r() && window() && this == Fl::belowmouse())
window()->cursor(FL_CURSOR_NONE);
return handle_key();
}
//NOTREACHED
*** END EXCERPTS ***
So on this note I quickly wrote a sample program yanking out the portions from
my production code and removing all the non-relevant stuff.
I put this as non-public on pastebin, hope that's okay
(http://pastebin.com/2giSYbpU)
Anyways, once compiled & run, Fl_Input has focus right away. Striking up/down
keys does nothing and the Fl_Table_Row handler prints nothing for FL_KEYDOWN,
but does for FL_KEYUP. Mouse-clicking in the table will allow you to scroll
up/down while holding the keys (I added an auto-scrolling functionality, not
sure if you have this anywhere in your code or ever done it?). A neat thing is
when you scroll back to the top of the table it jumps back into the Fl_Input
which is nice; but of course you can't jump back down into the table.
So the functionality I'm seeking is I should immediately be able to handle
FL_KEYDOWN in the table from inside Fl_Input even if it doesn't have focus -
but can't figure out why it's not happening. This probably seems like a
bizzare request on its own, but it's part of a larger more complex problem and
I'll save the long story behind it :)
Thanks infinitely,
Jeff
>
> Would need to see the code for your handle() function(s).
> The 0|1 values it returns are probably critical.
>
> Also, which version of FLTK and what operating system?
>
> FWIW, I added a handle() function to the the table-sort.cxx
> example program to print the events it received, and if I hold
> a key down, it repeatedly gets FL_KEYDOWN. Tested with fltk 1.3.x
> current svn on linux.
>
> I basically added this line at the top of the example:
>
> #include <FL/names.h>
>
> ..and added this method to its MyTable class:
>
> int handle(int e) {
> printf("EVENT %s (%d)\n", fl_eventnames[e],e);
> return Fl_Table_Row::handle(e);
> }
>
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk