зеркало из https://github.com/mozilla/pjs.git
Bug 630813 part.7 Implement IsKeyPressEventNecessary() in mozilla::widget::KeymapWrapper r=karlt
This commit is contained in:
Родитель
6ec24bfd10
Коммит
07d3a9d109
|
@ -942,5 +942,23 @@ KeymapWrapper::InitKeypressEvent(nsKeyEvent& aKeyEvent,
|
|||
altLatinCharCodes.mShiftedCharCode));
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
KeymapWrapper::IsKeyPressEventNecessary(GdkEventKey* aGdkKeyEvent)
|
||||
{
|
||||
// If this is a modifier key event, we shouldn't send keypress event.
|
||||
switch (ComputeDOMKeyCode(aGdkKeyEvent->keyval)) {
|
||||
case NS_VK_SHIFT:
|
||||
case NS_VK_CONTROL:
|
||||
case NS_VK_META:
|
||||
case NS_VK_ALT:
|
||||
case NS_VK_CAPS_LOCK:
|
||||
case NS_VK_NUM_LOCK:
|
||||
case NS_VK_SCROLL_LOCK:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -133,6 +133,12 @@ public:
|
|||
*/
|
||||
static void InitKeyEvent(nsKeyEvent& aKeyEvent, GdkEventKey* aGdkKeyEvent);
|
||||
|
||||
/**
|
||||
* IsKeyPressEventNecessary() returns TRUE when aGdkKeyEvent should cause
|
||||
* a DOM keypress event. Otherwise, FALSE.
|
||||
*/
|
||||
static bool IsKeyPressEventNecessary(GdkEventKey* aGdkKeyEvent);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -2996,14 +2996,7 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
|
|||
// TODO: Instead of selectively excluding some keys from NS_KEY_PRESS events,
|
||||
// we should instead selectively include (as per MSDN spec; no official
|
||||
// spec covers KeyPress events).
|
||||
if (aEvent->keyval == GDK_Shift_L
|
||||
|| aEvent->keyval == GDK_Shift_R
|
||||
|| aEvent->keyval == GDK_Control_L
|
||||
|| aEvent->keyval == GDK_Control_R
|
||||
|| aEvent->keyval == GDK_Alt_L
|
||||
|| aEvent->keyval == GDK_Alt_R
|
||||
|| aEvent->keyval == GDK_Meta_L
|
||||
|| aEvent->keyval == GDK_Meta_R) {
|
||||
if (!KeymapWrapper::IsKeyPressEventNecessary(aEvent)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче