summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2012-12-15 14:19:42 +0000
committerManolo Gouy <Manolo>2012-12-15 14:19:42 +0000
commit22b4198e4556660d6bb95571c7205bf2f23b901e (patch)
tree020639c024831965cecfc53edb58a15f569dedf1 /src
parent5a054cd1b353d8805bf4351905e06be51e5e9077 (diff)
Mac OS: fixed [FLView keyDown:] for OS 10.3
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9755 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 9762d8420..bb2ab9662 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -897,6 +897,7 @@ static void cocoaMouseHandler(NSEvent *theEvent)
// this subclass is needed under OS X <= 10.5 but not under >= 10.6 where the base class is enough
{
}
+- (void)interpretKeyEvents:(NSArray *)eventArray;
@end
@implementation FLTextView
- (void)insertText:(id)aString
@@ -907,6 +908,24 @@ static void cocoaMouseHandler(NSEvent *theEvent)
{
[[[NSApp keyWindow] contentView] doCommandBySelector:aSelector];
}
+- (void)interpretKeyEvents:(NSArray *)eventArray
+{
+ if (Fl::e_keysym == FL_BackSpace || Fl::e_keysym == FL_KP_Enter ||
+ Fl::e_keysym == FL_Enter || Fl::e_keysym == FL_Escape || Fl::e_keysym == FL_Tab ) {
+ NSEvent *theEvent = (NSEvent*)[eventArray objectAtIndex:0];
+ // interpretKeyEvents doesn't output anything for these 5 keys under 10.5 or below
+ NSString *s = [theEvent characters];
+ if ([s length] >= 1) {
+ static char utf[2] = {0, 0};
+ utf[0] = [s UTF8String][0];
+ Fl::e_text = utf;
+ Fl::e_length = 1;
+ }
+ Fl_Window *window = [(FLWindow*)[theEvent window] getFl_Window];
+ Fl::handle(FL_KEYBOARD, window);
+ }
+ else [super interpretKeyEvents:eventArray];
+}
@end
/*
@@ -1745,20 +1764,11 @@ static void q_set_window_title(NSWindow *nsw, const char * name, const char *mi
// First let's process the raw key press
cocoaKeyboardHandler(theEvent);
-
- if (fl_mac_os_version < 100600 && (Fl::e_keysym == FL_BackSpace ||
- Fl::e_keysym == FL_Enter || Fl::e_keysym == FL_Escape || Fl::e_keysym == FL_Tab) ) {
- // interpretKeyEvents doesn't output anything for these 4 keys under 10.5 or below
- NSString *s = [theEvent characters];
- if ([s length] >= 1) [FLView prepareEtext:s];
- Fl::handle(FL_KEYBOARD, window);
- }
- else {
- NSText *edit = [[theEvent window] fieldEditor:YES forObject:nil];
- in_key_event = YES;
- [edit interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
- in_key_event = NO;
- }
+
+ NSText *edit = [[theEvent window] fieldEditor:YES forObject:nil];
+ in_key_event = YES;
+ [edit interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
+ in_key_event = NO;
fl_unlock_function();
}
- (void)keyUp:(NSEvent *)theEvent {