mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 23:06:54 +08:00
Restore emojis support under recent macOS versions (#1360)
This commit is contained in:
+19
-2
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// macOS-Cocoa specific code for the Fast Light Tool Kit (FLTK).
|
// macOS-Cocoa specific code for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 1998-2025 by Bill Spitzak and others.
|
// Copyright 1998-2026 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -94,6 +94,7 @@ static BOOL through_drawRect = NO;
|
|||||||
static BOOL through_Fl_X_flush = NO;
|
static BOOL through_Fl_X_flush = NO;
|
||||||
static BOOL views_use_CA = NO; // YES means views are layer-backed, as on macOS 10.14 when linked with SDK 10.14
|
static BOOL views_use_CA = NO; // YES means views are layer-backed, as on macOS 10.14 when linked with SDK 10.14
|
||||||
static int im_enabled = -1;
|
static int im_enabled = -1;
|
||||||
|
static Fl_Widget *previous_focus = NULL; // restore lost focus when character palette window appears
|
||||||
// OS version-dependent pasteboard type names.
|
// OS version-dependent pasteboard type names.
|
||||||
// Some, but not all, versions of the 10.6 SDK for PPC lack the 3 symbols below (PR #761)
|
// Some, but not all, versions of the 10.6 SDK for PPC lack the 3 symbols below (PR #761)
|
||||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6) || defined(__POWERPC__)
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6) || defined(__POWERPC__)
|
||||||
@@ -1438,6 +1439,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||||||
[nsw setLevel:NSNormalWindowLevel];
|
[nsw setLevel:NSNormalWindowLevel];
|
||||||
fixup_window_levels();
|
fixup_window_levels();
|
||||||
}
|
}
|
||||||
|
previous_focus = Fl::focus();
|
||||||
Fl::handle( FL_UNFOCUS, window);
|
Fl::handle( FL_UNFOCUS, window);
|
||||||
fl_unlock_function();
|
fl_unlock_function();
|
||||||
}
|
}
|
||||||
@@ -2514,10 +2516,16 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
|
|||||||
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent
|
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
//NSLog(@"performKeyEquivalent:");
|
//NSLog(@"performKeyEquivalent:");
|
||||||
|
NSUInteger mods = [theEvent modifierFlags];
|
||||||
|
NSString *pure = [theEvent charactersIgnoringModifiers];
|
||||||
|
// detect Function+e to open character palette
|
||||||
|
if ((mods & NSEventModifierFlagFunction) && [pure isEqualToString:@"e"] ) {
|
||||||
|
[NSApp orderFrontCharacterPalette:self];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
fl_lock_function();
|
fl_lock_function();
|
||||||
cocoaKeyboardHandler(theEvent);
|
cocoaKeyboardHandler(theEvent);
|
||||||
BOOL handled;
|
BOOL handled;
|
||||||
NSUInteger mods = [theEvent modifierFlags];
|
|
||||||
Fl_Window *w = [(FLWindow*)[theEvent window] getFl_Window];
|
Fl_Window *w = [(FLWindow*)[theEvent window] getFl_Window];
|
||||||
if ( (mods & NSEventModifierFlagControl) || (mods & NSEventModifierFlagCommand) ) {
|
if ( (mods & NSEventModifierFlagControl) || (mods & NSEventModifierFlagCommand) ) {
|
||||||
NSString *s = [theEvent characters];
|
NSString *s = [theEvent characters];
|
||||||
@@ -2527,6 +2535,13 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
|
|||||||
[FLView prepareEtext:s];
|
[FLView prepareEtext:s];
|
||||||
Fl::compose_state = 0;
|
Fl::compose_state = 0;
|
||||||
handled = Fl::handle(FL_KEYBOARD, w);
|
handled = Fl::handle(FL_KEYBOARD, w);
|
||||||
|
if (!handled) {
|
||||||
|
// detect Ctrl+Command+Space to open character palette, if not used before as shortcut
|
||||||
|
if ( (mods & NSEventModifierFlagControl) && (mods & NSEventModifierFlagCommand) &&
|
||||||
|
!(mods & (NSEventModifierFlagShift|NSEventModifierFlagOption)) && [pure isEqualToString:@" "] ) {
|
||||||
|
[NSApp orderFrontCharacterPalette:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
in_key_event = YES;
|
in_key_event = YES;
|
||||||
@@ -2874,7 +2889,9 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
|
|||||||
// insertText sent during handleEvent of a key without text cannot be processed in a single FL_KEYBOARD event.
|
// insertText sent during handleEvent of a key without text cannot be processed in a single FL_KEYBOARD event.
|
||||||
// Occurs with deadkey followed by non-text key
|
// Occurs with deadkey followed by non-text key
|
||||||
if (!in_key_event || !has_text_key) {
|
if (!in_key_event || !has_text_key) {
|
||||||
|
if (palette && !Fl::focus()) Fl::focus(previous_focus);
|
||||||
Fl::handle(FL_KEYBOARD, target);
|
Fl::handle(FL_KEYBOARD, target);
|
||||||
|
if (palette) previous_focus = NULL;
|
||||||
Fl::e_length = 0;
|
Fl::e_length = 0;
|
||||||
}
|
}
|
||||||
else need_handle = YES;
|
else need_handle = YES;
|
||||||
|
|||||||
Reference in New Issue
Block a user