improved FF deadkey detection

This commit is contained in:
daboe01 committed 2016-06-18 20:36:22 +02:00
1 parent f2d5dee49e
commit 631352e1ef
1 file changed
+8
+8
View File
@@ -2245,6 +2245,7 @@ var CPTextViewAllowsUndoKey = @"CPTextViewAllowsUndoKey",
var _CPNativeInputField,
_CPNativeInputFieldLastValue,
_CPNativeInputFieldKeyDownCalled,
_CPNativeInputFieldKeyUpCalled,
_CPNativeInputFieldKeyPressedCalled,
_CPNativeInputFieldActive,
@@ -2372,6 +2373,11 @@ var _CPCopyPlaceholder = '-';
_CPNativeInputField.addEventListener("keydown", function(e)
{
// this protects from heavy typing
if (CPBrowserIsEngine(CPGeckoBrowserEngine) && _CPNativeInputFieldKeyDownCalled)
return true;
_CPNativeInputFieldKeyDownCalled = YES;
_CPNativeInputFieldKeyUpCalled = NO;
_CPNativeInputFieldKeyPressedCalled = NO;
var currentFirstResponder = [[CPApp keyWindow] firstResponder];
@@ -2382,6 +2388,8 @@ var _CPCopyPlaceholder = '-';
// FF-trigger: here the best way to detect a dead key is the missing keyup event
if (CPBrowserIsEngine(CPGeckoBrowserEngine))
setTimeout(function(){
_CPNativeInputFieldKeyDownCalled = NO;
if (!_CPNativeInputFieldActive && _CPNativeInputFieldKeyUpCalled == NO && _CPNativeInputField.innerHTML.length && _CPNativeInputField.innerHTML != _CPCopyPlaceholder && _CPNativeInputField.innerHTML.length < 3 && !e.repeat)
{
_CPNativeInputFieldActive = YES;