mirror of
https://github.com/fltk/fltk.git
synced 2026-05-21 14:31:40 +08:00
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
This commit is contained in:
+24
-14
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user