Skip to content

Commit 3ca521c

Browse files
committed
Handle unrecognized keys without crashing.
1 parent 5c9581d commit 3ca521c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Graphics/UI/FLTK/LowLevel/Fl_Enumerations.chs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ enum SpecialKey {
314314
Kb_Refresh = FL_Refresh,
315315
Kb_Sleep = FL_Sleep,
316316
Kb_Favorites = FL_Favorites,
317+
Kb_Unrecognized,
317318
};
318319
enum MouseButton {
319320
Mouse_Left = FL_LEFT_MOUSE,

src/Graphics/UI/FLTK/LowLevel/Utils.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ cToKeyType cint =
311311
in
312312
case findSpecialKey of
313313
Just sk -> SpecialKeyType sk
314-
Nothing -> NormalKeyType (toEnum $ fromIntegral cint)
314+
Nothing -> if cint <= 0x10FFFF
315+
then NormalKeyType (toEnum $ fromIntegral cint)
316+
else SpecialKeyType Kb_Unrecognized
315317

316318
cFromKeyType :: KeyType -> CInt
317319
cFromKeyType kt = case kt of

0 commit comments

Comments
 (0)