steven marx wrote:
> my handler appears to interpret a depressed key (upon release)
> as multiple key presses. how can i detect that a key has been
> held down so that i can ignore the subsequent multiple events upon
> its release.

        Are you sure you're handling keyboard up/down events
        as described in the event docs:
        http://fltk.org/documentation.php/doc-1.1/events.html#7_4

        What's your handle() code look like?
        It should probably look something like this:

int MyWidget::handle(int e) {
    int ret = Fl_XXXXXXXX::handle(e);   // let base class handle event first
    switch ( e ) {
        case FL_FOCUS:
        case FL_UNFOCUS:
            // RESPOND TO FOCUS/UNFOCUS
            ret = 1;
            break;

        case FL_KEYDOWN:
            // KEY DOWN OR REPEATING
            fprintf(stderr, "KEY DOWN %s=%c\n", Fl::event_key());
            ret = 1;
            break;

        case FL_KEYUP:
            // KEY RELEASED
            fprintf(stderr, "KEY UP %s=%c\n", Fl::event_key());
            ret = 1;
            break;
    }
    return(ret);
}

        When someone hits a key you'll receive an initial FL_KEYDOWN event,
        and you can use Fl::event_key() to figure out which key went down.

        If the key is held down it will 'repeat'; you will get repeating
        FL_KEYDOWN events for the key (which you can ignore if you don't
        want them)

        When the key is released, you should receive a single FL_KEYUP
        event for that key, which should tell you the key has been released.
        Even if several keys are pushed and held at once, when you release,
        you should get one UP event for each.

        The FLTK 'keyboard' test program is a good example of how FLTK
        can track keypress/release events, even when chords of keys are pressed.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to