FL_KEYUP event support.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1661 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2001-10-27 03:45:29 +00:00
parent 06619abc5a
commit 831d7cde5b
3 changed files with 32 additions and 25 deletions

View File

@ -6,6 +6,7 @@ CHANGES IN FLTK 1.1.0b5
those boxtypes causing them to be reset.
- Fl_Help_Func now takes a Fl_Widget pointer as well as
a pathname.
- Added code to support FL_KEYUP events.
CHANGES IN FLTK 1.1.0b4

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_win32.cxx,v 1.33.2.37.2.4 2001/09/30 12:42:32 easysw Exp $"
// "$Id: Fl_win32.cxx,v 1.33.2.37.2.5 2001/10/27 03:45:29 easysw Exp $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
@ -576,7 +576,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
}
if (GetKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK;
Fl::e_state = state;
if (lParam & (1<<31)) goto DEFAULT; // ignore up events after fixing shift
if (lParam & (1<<31)) { // key up events.
if (Fl::handle(FL_KEYUP, window)) return 0;
break;
}
static char buffer[2];
if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) {
buffer[0] = char(wParam);
@ -998,5 +1001,5 @@ void Fl_Window::make_current() {
}
//
// End of "$Id: Fl_win32.cxx,v 1.33.2.37.2.4 2001/09/30 12:42:32 easysw Exp $".
// End of "$Id: Fl_win32.cxx,v 1.33.2.37.2.5 2001/10/27 03:45:29 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_x.cxx,v 1.24.2.24.2.3 2001/10/18 18:53:20 easysw Exp $"
// "$Id: Fl_x.cxx,v 1.24.2.24.2.4 2001/10/27 03:45:29 easysw Exp $"
//
// X specific code for the Fast Light Tool Kit (FLTK).
//
@ -487,19 +487,33 @@ int fl_handle(const XEvent& xevent)
event = FL_UNFOCUS;
break;
case KeyPress: {
case KeyPress:
case KeyRelease: {
int keycode = xevent.xkey.keycode;
fl_key_vector[keycode/8] |= (1 << (keycode%8));
static char buffer[21];
int len;
KeySym keysym;
//static XComposeStatus compose;
int len = XLookupString((XKeyEvent*)&(xevent.xkey),
buffer, 20, &keysym, 0/*&compose*/);
if (keysym && keysym < 0x400) { // a character in latin-1,2,3,4 sets
// force it to type a character (not sure if this ever is needed):
if (!len) {buffer[0] = char(keysym); len = 1;}
// ignore all effects of shift on the keysyms, which makes it a lot
// easier to program shortcuts and is Windoze-compatable:
if (xevent.type == KeyPress) {
event = FL_KEYDOWN;
//static XComposeStatus compose;
len = XLookupString((XKeyEvent*)&(xevent.xkey),
buffer, 20, &keysym, 0/*&compose*/);
if (keysym && keysym < 0x400) { // a character in latin-1,2,3,4 sets
// force it to type a character (not sure if this ever is needed):
if (!len) {buffer[0] = char(keysym); len = 1;}
// ignore all effects of shift on the keysyms, which makes it a lot
// easier to program shortcuts and is Windoze-compatable:
keysym = XKeycodeToKeysym(fl_display, keycode, 0);
}
if (Fl::event_state(FL_CTRL) && keysym == '-') buffer[0] = 0x1f; // ^_
buffer[len] = 0;
Fl::e_text = buffer;
Fl::e_length = len;
} else {
event = FL_KEYUP;
fl_key_vector[keycode/8] &= ~(1 << (keycode%8));
// keyup events just get the unshifted keysym:
keysym = XKeycodeToKeysym(fl_display, keycode, 0);
}
#ifdef __sgi
@ -545,22 +559,11 @@ int fl_handle(const XEvent& xevent)
keysym = table[keysym-0xff91];
}
}
buffer[len] = 0;
Fl::e_keysym = int(keysym);
Fl::e_text = buffer;
Fl::e_length = len;
set_event_xy();
Fl::e_is_click = 0;
if (Fl::event_state(FL_CTRL) && keysym == '-') buffer[0] = 0x1f; // ^_
event = FL_KEYBOARD;
break;}
case KeyRelease: {
int keycode = xevent.xkey.keycode;
fl_key_vector[keycode/8] &= ~(1 << (keycode%8));
set_event_xy();}
break;
case EnterNotify:
if (xevent.xcrossing.detail == NotifyInferior) break;
// XInstallColormap(fl_display, Fl_X::i(window)->colormap);
@ -931,5 +934,5 @@ void Fl_Window::make_current() {
#endif
//
// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.3 2001/10/18 18:53:20 easysw Exp $".
// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.4 2001/10/27 03:45:29 easysw Exp $".
//