зеркало из https://github.com/mozilla/pjs.git
Bug 477291 Should not send keypress event before calling interpretKeyEvents r=smichaud
This commit is contained in:
Родитель
e756688298
Коммит
318761046e
|
@ -1054,30 +1054,6 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
|
|||
// Bail, there is nothing else to do here.
|
||||
return (cmEventHandled || currentKeyEvent->KeyDownOrPressHandled());
|
||||
}
|
||||
|
||||
nsKeyEvent keypressEvent(true, NS_KEY_PRESS, mWidget);
|
||||
InitKeyEvent(aNativeEvent, keypressEvent);
|
||||
|
||||
// if this is a non-letter keypress, or the control key is down,
|
||||
// dispatch the keydown to gecko, so that we trap delete,
|
||||
// control-letter combinations etc before Cocoa tries to use
|
||||
// them for keybindings.
|
||||
// XXX This is wrong. IME may be handle the non-letter keypress event as
|
||||
// its owning shortcut key. See bug 477291.
|
||||
if ((!keypressEvent.isChar || keypressEvent.isControl) &&
|
||||
!IsIMEComposing()) {
|
||||
if (currentKeyEvent->mKeyDownHandled) {
|
||||
keypressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
currentKeyEvent->mKeyPressHandled = DispatchEvent(keypressEvent);
|
||||
currentKeyEvent->mKeyPressDispatched = true;
|
||||
if (Destroyed()) {
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("%p TextInputHandler::HandleKeyDownEvent, "
|
||||
"widget was destroyed by keypress event", this));
|
||||
return currentKeyEvent->KeyDownOrPressHandled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Let Cocoa interpret the key events, caching IsIMEComposing first.
|
||||
|
@ -1416,6 +1392,8 @@ TextInputHandler::InsertText(NSAttributedString *aAttrString)
|
|||
bool
|
||||
TextInputHandler::DoCommandBySelector(const char* aSelector)
|
||||
{
|
||||
nsRefPtr<nsChildView> kungFuDeathGrip(mWidget);
|
||||
|
||||
KeyEventState* currentKeyEvent = GetCurrentKeyEvent();
|
||||
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
|
@ -1427,6 +1405,22 @@ TextInputHandler::DoCommandBySelector(const char* aSelector)
|
|||
currentKeyEvent ?
|
||||
TrueOrFalse(currentKeyEvent->mCausedOtherKeyEvents) : "N/A"));
|
||||
|
||||
if (currentKeyEvent && !currentKeyEvent->mKeyPressDispatched) {
|
||||
nsKeyEvent keypressEvent(true, NS_KEY_PRESS, mWidget);
|
||||
InitKeyEvent(currentKeyEvent->mKeyEvent, keypressEvent);
|
||||
if (currentKeyEvent->mKeyDownHandled ||
|
||||
currentKeyEvent->mCausedOtherKeyEvents) {
|
||||
keypressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
currentKeyEvent->mKeyPressHandled = DispatchEvent(keypressEvent);
|
||||
currentKeyEvent->mKeyPressDispatched = true;
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("%p TextInputHandler::DoCommandBySelector, keypress event "
|
||||
"dispatched, Destroyed()=%s, keypressHandled=%s",
|
||||
this, TrueOrFalse(Destroyed()),
|
||||
TrueOrFalse(currentKeyEvent->mKeyPressHandled)));
|
||||
}
|
||||
|
||||
return !Destroyed() && currentKeyEvent &&
|
||||
(currentKeyEvent->mKeyPressHandled ||
|
||||
currentKeyEvent->mCausedOtherKeyEvents);
|
||||
|
|
Загрузка…
Ссылка в новой задаче