Enable ApplePressAndHoldEnabled
Fixes https://github.com/libsdl-org/SDL/issues/3622
This commit is contained in:
parent
900627f7fc
commit
caf0348b26
2 changed files with 14 additions and 8 deletions
|
@ -110,7 +110,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
|||
|
||||
NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:momentumScrollSupported], @"AppleMomentumScrollSupported",
|
||||
[NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled",
|
||||
[NSNumber numberWithBool:YES], @"ApplePressAndHoldEnabled",
|
||||
[NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
|
||||
nil];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
|
||||
|
|
|
@ -59,11 +59,10 @@
|
|||
|
||||
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||
{
|
||||
// TODO: Make use of replacementRange?
|
||||
|
||||
const char *str;
|
||||
|
||||
DEBUG_IME(@"insertText: %@", aString);
|
||||
DEBUG_IME(@"insertText: %@ replacementRange: (%d, %d)", aString,
|
||||
(int)replacementRange.location, (int)replacementRange.length);
|
||||
|
||||
/* Could be NSString or NSAttributedString, so we have
|
||||
* to test and convert it before return as SDL event */
|
||||
|
@ -81,6 +80,12 @@
|
|||
// Deliver the raw key event that generated this text
|
||||
[self sendPendingKey];
|
||||
|
||||
if ((int)replacementRange.location != -1) {
|
||||
// We're replacing the last character
|
||||
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_BACKSPACE, true);
|
||||
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_BACKSPACE, false);
|
||||
}
|
||||
|
||||
SDL_SendKeyboardText(str);
|
||||
}
|
||||
|
||||
|
@ -131,8 +136,9 @@
|
|||
SDL_SendEditingText([aString UTF8String],
|
||||
(int)selectedRange.location, (int)selectedRange.length);
|
||||
|
||||
DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText,
|
||||
selectedRange.location, selectedRange.length);
|
||||
DEBUG_IME(@"setMarkedText: %@, (%d, %d) replacement range (%d, %d)", _markedText,
|
||||
(int)selectedRange.location, (int)selectedRange.length,
|
||||
(int)replacementRange.location, (int)replacementRange.length);
|
||||
}
|
||||
|
||||
- (void)unmarkText
|
||||
|
@ -158,7 +164,7 @@
|
|||
}
|
||||
|
||||
DEBUG_IME(@"firstRectForCharacterRange: (%d, %d): windowHeight = %g, rect = %@",
|
||||
aRange.location, aRange.length, windowHeight,
|
||||
(int)aRange.location, (int)aRange.length, windowHeight,
|
||||
NSStringFromRect(rect));
|
||||
|
||||
rect = [window convertRectToScreen:rect];
|
||||
|
@ -168,7 +174,7 @@
|
|||
|
||||
- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange
|
||||
{
|
||||
DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", aRange.location, aRange.length);
|
||||
DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", (int)aRange.location, (int)aRange.length);
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue