possible keypad shortcut bug or docs typo

9 views
Skip to first unread message

Robert Arkiletian

unread,
Nov 23, 2020, 2:10:53 AM11/23/20
to fltk.general
In the code below. The keypad number 5 requires the addition of the char (in single qoutes) of the number to FL_KP but for the F5 key it requires an integer. This doesn't seem consistent. The 1.3.5 docs under Enumerations specify adding an int not a char. So is this a bug or a typo in the docs? See the test code below. BTW I know a char is interpreted as an int for addition but '5' != 5

#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>

void foo(Fl_Widget* o){
   printf("5 pressed\n");
}

int main() {
 Fl_Window *window = new Fl_Window(200,200,300,300);
 Fl_Button *b = new Fl_Button(0, 0, 130, 40,"keypad 5");
 b->callback(foo);
 b->shortcut(FL_KP+5);   //does not work
 //b->shortcut(FL_KP+'5'); //works when adding char
 //b->shortcut(FL_F+5);    // works when adding an int
 //b->shortcut(FL_F+'5');   //does not work
 window->end();
 window->show();
 return Fl::run();
}

Manolo

unread,
Nov 23, 2020, 5:52:04 AM11/23/20
to fltk.general
The git repository of FLTK 1.4 has now been changed to clarify this point.
Changes will soon appear in
and

Since keypad keys are not all associated to a number, they are named such as
FL_KP + '2' and FL_KP + '='
Functions keys are instead all unambiguously designed by FL_F + n
where n is a number.

Robert Arkiletian

unread,
Nov 23, 2020, 2:23:14 PM11/23/20
to fltkg...@googlegroups.com
Thanks for updating the docs.
Reply all
Reply to author
Forward
0 new messages