зеркало из https://github.com/mozilla/gecko-dev.git
Bug 167145. When PreventDefault() called for onkeydown event, do the same for onkeypress that follows. r=bryner, sr=neil
This commit is contained in:
Родитель
c4f9945247
Коммит
84910111ef
|
@ -145,16 +145,8 @@ nsMenuListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
|
||||
// Since a menu was open, eat the event to keep other event
|
||||
// listeners from becoming confused.
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
||||
|
||||
if (nsevent) {
|
||||
nsevent->PreventBubble();
|
||||
nsevent->PreventCapture();
|
||||
}
|
||||
|
||||
aKeyEvent->StopPropagation();
|
||||
aKeyEvent->PreventDefault();
|
||||
|
||||
return NS_ERROR_BASE; // I am consuming event
|
||||
}
|
||||
|
||||
|
@ -162,15 +154,10 @@ nsMenuListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
nsresult
|
||||
nsMenuListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
// if event has already been handled, bail
|
||||
nsCOMPtr<nsIDOMNSUIEvent> uiEvent ( do_QueryInterface(aKeyEvent) );
|
||||
if ( uiEvent ) {
|
||||
PRBool eventHandled = PR_FALSE;
|
||||
uiEvent->GetPreventDefault ( &eventHandled );
|
||||
if ( eventHandled )
|
||||
return NS_OK; // don't consume event
|
||||
}
|
||||
|
||||
// Don't check prevent default flag -- menus always get first shot at key events.
|
||||
// When a menu is open, the prevent default flag on a keypress is always set, so
|
||||
// that no one else uses the key event.
|
||||
|
||||
//handlers shouldn't be triggered by non-trusted events.
|
||||
nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aKeyEvent);
|
||||
PRBool trustedEvent = PR_FALSE;
|
||||
|
@ -229,15 +216,8 @@ nsMenuListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
||||
|
||||
if (nsevent) {
|
||||
nsevent->PreventBubble();
|
||||
nsevent->PreventCapture();
|
||||
}
|
||||
|
||||
aKeyEvent->StopPropagation();
|
||||
aKeyEvent->PreventDefault();
|
||||
|
||||
return NS_ERROR_BASE; // I am consuming event
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@ public:
|
|||
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
NS_IMETHOD KeyUp(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
|
|
|
@ -2155,7 +2155,7 @@ PRBool nsWindow::OnKeyDown(PRUint32 aEventType, const char *bytes,
|
|||
int32 numBytes, PRUint32 mod, PRUint32 bekeycode, int32 rawcode)
|
||||
{
|
||||
PRUint32 aTranslatedKeyCode;
|
||||
PRBool result = PR_FALSE;
|
||||
PRBool noDefault = PR_FALSE;
|
||||
|
||||
mIsShiftDown = (mod & B_SHIFT_KEY) ? PR_TRUE : PR_FALSE;
|
||||
mIsControlDown = (mod & B_CONTROL_KEY) ? PR_TRUE : PR_FALSE;
|
||||
|
@ -2171,7 +2171,7 @@ PRBool nsWindow::OnKeyDown(PRUint32 aEventType, const char *bytes,
|
|||
|
||||
if (numBytes <= 1)
|
||||
{
|
||||
result = DispatchKeyEvent(NS_KEY_DOWN, 0, aTranslatedKeyCode);
|
||||
noDefault = DispatchKeyEvent(NS_KEY_DOWN, 0, aTranslatedKeyCode);
|
||||
} else {
|
||||
// non ASCII chars
|
||||
}
|
||||
|
@ -2187,13 +2187,13 @@ PRBool nsWindow::OnKeyDown(PRUint32 aEventType, const char *bytes,
|
|||
aTranslatedKeyCode = 0;
|
||||
} else {
|
||||
if (numBytes == 0) // deal with unmapped key
|
||||
return result;
|
||||
return noDefault;
|
||||
|
||||
switch((unsigned char)bytes[0])
|
||||
{
|
||||
case 0xc8://System Request
|
||||
case 0xca://Break
|
||||
return result;// do not send 'KEY_PRESS' message
|
||||
return noDefault;// do not send 'KEY_PRESS' message
|
||||
|
||||
case B_INSERT:
|
||||
case B_ESCAPE:
|
||||
|
@ -2238,9 +2238,9 @@ PRBool nsWindow::OnKeyDown(PRUint32 aEventType, const char *bytes,
|
|||
}
|
||||
}
|
||||
|
||||
PRBool result2 = DispatchKeyEvent(NS_KEY_PRESS, uniChar, aTranslatedKeyCode);
|
||||
|
||||
return result && result2;
|
||||
// If prevent default set for onkeydown, do the same for onkeypress
|
||||
PRUint32 extraFlags = (noDefault ? NS_EVENT_FLAG_NO_DEFAULT : 0);
|
||||
return DispatchKeyEvent(NS_KEY_PRESS, uniChar, aTranslatedKeyCode, extraFlags) && noDefault;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -2273,7 +2273,7 @@ PRBool nsWindow::OnKeyUp(PRUint32 aEventType, const char *bytes,
|
|||
//-------------------------------------------------------------------------
|
||||
|
||||
PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, PRUint32 aCharCode,
|
||||
PRUint32 aKeyCode)
|
||||
PRUint32 aKeyCode, PRUint32 aFlags)
|
||||
{
|
||||
nsKeyEvent event(aEventType, this);
|
||||
nsPoint point;
|
||||
|
@ -2283,6 +2283,7 @@ PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, PRUint32 aCharCode,
|
|||
|
||||
InitEvent(event, &point); // this add ref's event.widget
|
||||
|
||||
event.flags |= aFlags;
|
||||
event.charCode = aCharCode;
|
||||
event.keyCode = aKeyCode;
|
||||
|
||||
|
|
|
@ -206,7 +206,8 @@ protected:
|
|||
PRUint32 mod,
|
||||
PRUint32 bekeycode,
|
||||
int32 rawcode);
|
||||
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, PRUint32 aCharCode, PRUint32 aKeyCode);
|
||||
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, PRUint32 aCharCode,
|
||||
PRUint32 aKeyCode, PRUint32 aFlags = 0);
|
||||
virtual PRBool DispatchFocus(PRUint32 aEventType);
|
||||
virtual PRBool OnScroll();
|
||||
static PRBool ConvertStatus(nsEventStatus aStatus);
|
||||
|
|
|
@ -477,7 +477,7 @@ gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event,
|
|||
NS_ADDREF(win);
|
||||
nsKeyEvent keyDownEvent(NS_KEY_DOWN, win);
|
||||
InitKeyEvent(event, keyDownEvent);
|
||||
win->OnKey(keyDownEvent);
|
||||
PRBool noDefault = win->OnKey(keyDownEvent);
|
||||
|
||||
// Don't pass Shift, Control, Alt and Meta as NS_KEY_PRESS events.
|
||||
if (event->keyval == GDK_Shift_L
|
||||
|
@ -498,6 +498,10 @@ gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event,
|
|||
//
|
||||
nsKeyEvent keyPressEvent(NS_KEY_PRESS, win);
|
||||
InitKeyPressEvent(event, keyPressEvent);
|
||||
if (noDefault) { // If prevent default set for onkeydown, do the same for onkeypress
|
||||
event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
|
||||
win->OnKey(keyPressEvent);
|
||||
|
||||
NS_RELEASE(win);
|
||||
|
@ -552,13 +556,14 @@ gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p)
|
|||
// but lie about where it came from and say it is from the
|
||||
// window that currently has focus inside our app...
|
||||
//
|
||||
PRBool noDefault = PR_FALSE;
|
||||
nsKeyEvent keyDownEvent(NS_KEY_DOWN, win);
|
||||
InitKeyEvent(event, keyDownEvent);
|
||||
// if we need to suppress this NS_KEY_DOWN event, reset the flag
|
||||
if (suppressNextKeyDown == PR_TRUE)
|
||||
suppressNextKeyDown = PR_FALSE;
|
||||
else
|
||||
win->OnKey(keyDownEvent);
|
||||
noDefault = win->OnKey(keyDownEvent);
|
||||
|
||||
// Don't pass Shift, Alt, Control and Meta as NS_KEY_PRESS events.
|
||||
if (event->keyval == GDK_Shift_L
|
||||
|
@ -580,6 +585,9 @@ gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p)
|
|||
// Call nsConvertCharCodeToUnicode() here to get kevent.charCode
|
||||
nsKeyEvent keyPressEvent(NS_KEY_PRESS, win);
|
||||
InitKeyPressEvent(event, keyPressEvent);
|
||||
if (noDefault) { // If prevent default set for onkeydown, do the same for onkeypress
|
||||
event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
|
||||
if (event->length) {
|
||||
if (keyPressEvent.charCode || keyPressEvent.keyCode) {
|
||||
|
|
|
@ -1571,6 +1571,10 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
|
|||
}
|
||||
nsKeyEvent event(NS_KEY_PRESS, this);
|
||||
InitKeyEvent(event, aEvent);
|
||||
if (status == nsEventStatus_eConsumeNoDefault) {
|
||||
// If prevent default set for onkeydown, do the same for onkeypress
|
||||
event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
event.charCode = nsConvertCharCodeToUnicode(aEvent);
|
||||
if (event.charCode) {
|
||||
event.keyCode = 0;
|
||||
|
|
|
@ -1167,6 +1167,10 @@ PRBool nsMacEventHandler::HandleKeyEvent(EventRecord& aOSEvent)
|
|||
return result;
|
||||
|
||||
InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget, NS_KEY_PRESS);
|
||||
if (result) {
|
||||
// If keydown default was prevented, do same for keypress
|
||||
keyPressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
|
||||
// before we dispatch this key, check if it's the contextmenu key.
|
||||
// If so, send a context menu event instead.
|
||||
|
|
|
@ -2274,6 +2274,9 @@ PRBool nsWindow::OnKey( MPARAM mp1, MPARAM mp2)
|
|||
// Now we need to dispatch a keypress event which has the unicode char.
|
||||
|
||||
pressEvent.message = NS_KEY_PRESS;
|
||||
if (rc) { // If keydown default was prevented, do same for keypress
|
||||
pressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
|
||||
if( usChar)
|
||||
{
|
||||
|
|
|
@ -884,10 +884,13 @@ PRBool nsWidget::DispatchKeyEvent( PhKeyEvent_t *aPhKeyEvent ) {
|
|||
if (aPhKeyEvent->key_flags & Pk_KF_Key_Down) {
|
||||
nsKeyEvent keyDownEvent(NS_KEY_DOWN, w);
|
||||
InitKeyEvent(aPhKeyEvent, keyDownEvent);
|
||||
w->OnKey(keyDownEvent);
|
||||
PRBool noDefault = w->OnKey(keyDownEvent);
|
||||
|
||||
nsKeyEvent keyPressEvent(NS_KEY_PRESS, w);
|
||||
InitKeyPressEvent(aPhKeyEvent, keyPressEvent);
|
||||
if (noDefault) { // If prevent default set for keydown, do same for keypress
|
||||
keyPressEvent.flags = NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
w->OnKey(keyPressEvent);
|
||||
}
|
||||
else if (aPhKeyEvent->key_flags & Pk_KF_Key_Repeat) {
|
||||
|
|
|
@ -991,28 +991,31 @@ nsCommonWidget::keyPressEvent(QKeyEvent *e)
|
|||
// release. gtk2 already filters the extra key release events for
|
||||
// us.
|
||||
|
||||
nsKeyEvent pressEvent(NS_KEY_PRESS, this);
|
||||
InitKeyEvent(&pressEvent, e);
|
||||
pressEvent.charCode = (PRInt32)e->text()[0].unicode();
|
||||
|
||||
if (!e->isAutoRepeat()) {
|
||||
|
||||
// send the key down event
|
||||
nsKeyEvent downEvent(NS_KEY_DOWN, this);
|
||||
InitKeyEvent(&downEvent, e);
|
||||
DispatchEvent(&downEvent, status);
|
||||
if (ignoreEvent(status)) { // If prevent default on keydown, do same for keypress
|
||||
pressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
nsKeyEvent event(NS_KEY_PRESS, this);
|
||||
InitKeyEvent(&event, e);
|
||||
event.charCode = (PRInt32)e->text()[0].unicode();
|
||||
|
||||
// before we dispatch a key, check if it's the context menu key.
|
||||
// If so, send a context menu key event instead.
|
||||
if (isContextMenuKey(event)) {
|
||||
if (isContextMenuKey(pressEvent)) {
|
||||
nsMouseEvent contextMenuEvent;
|
||||
keyEventToContextMenuEvent(&event, &contextMenuEvent);
|
||||
keyEventToContextMenuEvent(&pressEvent, &contextMenuEvent);
|
||||
DispatchEvent(&contextMenuEvent, status);
|
||||
}
|
||||
else {
|
||||
// send the key press event
|
||||
DispatchEvent(&event, status);
|
||||
DispatchEvent(&pressEvent, status);
|
||||
}
|
||||
|
||||
return ignoreEvent(status);
|
||||
|
|
|
@ -2987,13 +2987,15 @@ UINT nsWindow::MapFromNativeToDOM(UINT aNativeKeyCode)
|
|||
// OnKey
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode, LPARAM aKeyData)
|
||||
PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode,
|
||||
LPARAM aKeyData, PRUint32 aFlags)
|
||||
{
|
||||
nsKeyEvent event(aEventType, this);
|
||||
nsPoint point(0, 0);
|
||||
|
||||
InitEvent(event, &point); // this add ref's event.widget
|
||||
|
||||
event.flags |= aFlags;
|
||||
event.charCode = aCharCode;
|
||||
event.keyCode = aVirtualCharCode;
|
||||
|
||||
|
@ -3060,7 +3062,7 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
|
|||
//printf("In OnKeyDown virt: %d scan: %d\n", virtualKeyCode, aScanCode);
|
||||
#endif
|
||||
|
||||
BOOL result = DispatchKeyEvent(NS_KEY_DOWN, 0, virtualKeyCode, aKeyData);
|
||||
BOOL noDefault = DispatchKeyEvent(NS_KEY_DOWN, 0, virtualKeyCode, aKeyData);
|
||||
|
||||
// If we won't be getting a WM_CHAR, WM_SYSCHAR or WM_DEADCHAR, synthesize a keypress
|
||||
// for almost all keys
|
||||
|
@ -3070,9 +3072,11 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
|
|||
case NS_VK_ALT:
|
||||
case NS_VK_CAPS_LOCK:
|
||||
case NS_VK_NUM_LOCK:
|
||||
case NS_VK_SCROLL_LOCK: return result;
|
||||
case NS_VK_SCROLL_LOCK: return noDefault;
|
||||
}
|
||||
|
||||
PRUint32 extraFlags = (noDefault ? NS_EVENT_FLAG_NO_DEFAULT : 0);
|
||||
|
||||
MSG msg;
|
||||
BOOL gotMsg = ::PeekMessage(&msg, mWnd, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD);
|
||||
// Enter and backspace are always handled here to avoid for example the
|
||||
|
@ -3123,7 +3127,9 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
|
|||
}
|
||||
else if (gotMsg &&
|
||||
(msg.message == WM_CHAR || msg.message == WM_SYSCHAR || msg.message == WM_DEADCHAR)) {
|
||||
return result;
|
||||
// If prevent default set for keydown, do same for keypress
|
||||
::GetMessage(&msg, mWnd, msg.message, msg.message);
|
||||
return (msg.message == WM_DEADCHAR) ? PR_FALSE : OnChar(msg.wParam, extraFlags);
|
||||
}
|
||||
|
||||
WORD asciiKey = 0;
|
||||
|
@ -3161,12 +3167,13 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
|
|||
asciiKey += 0x20;
|
||||
}
|
||||
}
|
||||
if (asciiKey)
|
||||
DispatchKeyEvent(NS_KEY_PRESS, asciiKey, 0, aKeyData);
|
||||
else
|
||||
DispatchKeyEvent(NS_KEY_PRESS, 0, virtualKeyCode, aKeyData);
|
||||
|
||||
return result;
|
||||
if (asciiKey)
|
||||
DispatchKeyEvent(NS_KEY_PRESS, asciiKey, 0, aKeyData, extraFlags);
|
||||
else
|
||||
DispatchKeyEvent(NS_KEY_PRESS, 0, virtualKeyCode, aKeyData, extraFlags);
|
||||
|
||||
return noDefault;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -3185,8 +3192,28 @@ BOOL nsWindow::OnKeyUp( UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
|
|||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
BOOL nsWindow::OnChar(UINT charCode)
|
||||
BOOL nsWindow::OnChar(UINT charCode, PRUint32 aFlags)
|
||||
{
|
||||
#ifdef KE_DEBUG
|
||||
printf("%s\tchar=%c\twp=%4x\tlp=%8x\n", (msg == WM_SYSCHAR) ? "WM_SYSCHAR" : "WM_CHAR" , wParam, wParam, lParam);
|
||||
#endif
|
||||
// These must be checked here too as a lone WM_CHAR could be received
|
||||
// if a child window didn't handle it (for example Alt+Space in a content window)
|
||||
mIsShiftDown = IS_VK_DOWN(NS_VK_SHIFT);
|
||||
mIsControlDown = IS_VK_DOWN(NS_VK_CONTROL);
|
||||
mIsAltDown = IS_VK_DOWN(NS_VK_ALT);
|
||||
|
||||
// ignore [shift+]alt+space so the OS can handle it
|
||||
if (mIsAltDown && !mIsControlDown && IS_VK_DOWN(NS_VK_SPACE)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// WM_CHAR with Control and Alt (== AltGr) down really means a normal character
|
||||
PRBool saveIsAltDown = mIsAltDown;
|
||||
PRBool saveIsControlDown = mIsControlDown;
|
||||
if (mIsAltDown && mIsControlDown)
|
||||
mIsAltDown = mIsControlDown = PR_FALSE;
|
||||
|
||||
wchar_t uniChar;
|
||||
|
||||
if (sIMEIsComposing) {
|
||||
|
@ -3228,6 +3255,8 @@ BOOL nsWindow::OnChar(UINT charCode)
|
|||
charToConvert[0] = LOBYTE(charCode);
|
||||
if (::IsDBCSLeadByteEx(gCurrentKeyboardCP, charToConvert[0])) {
|
||||
mLeadByte = charToConvert[0];
|
||||
mIsAltDown = saveIsAltDown;
|
||||
mIsControlDown = saveIsControlDown;
|
||||
return TRUE;
|
||||
}
|
||||
length = 1;
|
||||
|
@ -3246,7 +3275,11 @@ BOOL nsWindow::OnChar(UINT charCode)
|
|||
charCode = 0;
|
||||
}
|
||||
}
|
||||
return DispatchKeyEvent(NS_KEY_PRESS, uniChar, charCode, 0);
|
||||
|
||||
PRBool result = DispatchKeyEvent(NS_KEY_PRESS, uniChar, charCode, 0, aFlags);
|
||||
mIsAltDown = saveIsAltDown;
|
||||
mIsControlDown = saveIsControlDown;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3909,31 +3942,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||
case WM_SYSCHAR:
|
||||
case WM_CHAR:
|
||||
{
|
||||
#ifdef KE_DEBUG
|
||||
printf("%s\tchar=%c\twp=%4x\tlp=%8x\n", (msg == WM_SYSCHAR) ? "WM_SYSCHAR" : "WM_CHAR" , wParam, wParam, lParam);
|
||||
#endif
|
||||
// These must be checked here too as a lone WM_CHAR could be received
|
||||
// if a child window didn't handle it (for example Alt+Space in a content window)
|
||||
mIsShiftDown = IS_VK_DOWN(NS_VK_SHIFT);
|
||||
mIsControlDown = IS_VK_DOWN(NS_VK_CONTROL);
|
||||
mIsAltDown = IS_VK_DOWN(NS_VK_ALT);
|
||||
|
||||
// ignore [shift+]alt+space so the OS can handle it
|
||||
if (mIsAltDown && !mIsControlDown && IS_VK_DOWN(NS_VK_SPACE)) {
|
||||
result = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
// WM_CHAR with Control and Alt (== AltGr) down really means a normal character
|
||||
PRBool saveIsAltDown = mIsAltDown;
|
||||
PRBool saveIsControlDown = mIsControlDown;
|
||||
if (mIsAltDown && mIsControlDown)
|
||||
mIsAltDown = mIsControlDown = PR_FALSE;
|
||||
|
||||
result = OnChar(wParam);
|
||||
|
||||
mIsAltDown = saveIsAltDown;
|
||||
mIsControlDown = saveIsControlDown;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -434,7 +434,7 @@ protected:
|
|||
virtual PRBool OnPaint(HDC aDC = nsnull);
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
|
||||
BOOL OnChar(UINT charCode);
|
||||
BOOL OnChar(UINT charCode, PRUint32 aFlags = 0);
|
||||
|
||||
BOOL OnKeyDown( UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyCode);
|
||||
BOOL OnKeyUp( UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyCode);
|
||||
|
@ -455,7 +455,8 @@ protected:
|
|||
|
||||
void GetCompositionString(HIMC aHIMC, DWORD aIndex, nsString* aStrUnicode, nsCString* aStrAnsi);
|
||||
|
||||
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode, LPARAM aKeyCode);
|
||||
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode,
|
||||
LPARAM aKeyCode, PRUint32 aFlags = 0);
|
||||
|
||||
virtual PRBool DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocus);
|
||||
virtual PRBool OnScroll(UINT scrollCode, int cPos);
|
||||
|
|
|
@ -895,7 +895,7 @@ nsAppShell::HandleKeyPressEvent(XEvent *event, nsWidget *aWidget)
|
|||
// event->xkey.keycode,
|
||||
// keyEvent.keyCode);
|
||||
|
||||
focusWidget->DispatchKeyEvent(keyEvent);
|
||||
PRBool noDefault = focusWidget->DispatchKeyEvent(keyEvent);
|
||||
|
||||
nsKeyEvent pressEvent(NS_KEY_PRESS, focusWidget);
|
||||
pressEvent.keyCode = nsKeyCode::ConvertKeySymToVirtualKey(keysym);
|
||||
|
@ -905,9 +905,11 @@ nsAppShell::HandleKeyPressEvent(XEvent *event, nsWidget *aWidget)
|
|||
pressEvent.isControl = (event->xkey.state & ControlMask) ? 1 : 0;
|
||||
pressEvent.isAlt = (event->xkey.state & Mod1Mask) ? 1 : 0;
|
||||
pressEvent.isMeta = (event->xkey.state & Mod1Mask) ? 1 : 0;
|
||||
if (noDefault) { // If default prevented on keydown, do same for keypress
|
||||
pressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
|
||||
focusWidget->DispatchKeyEvent(pressEvent);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче