From 2b75e4e24e86a0abb3c1a5e3cc8cd7d262570297 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Thu, 25 Mar 1999 03:41:07 +0000 Subject: [PATCH] Remove the Enter->Return key hackery, as this is done now when the key event is generated. --- widget/src/mac/nsTextAreaWidget.cpp | 21 ++++++++++++--------- widget/src/mac/nsTextWidget.cpp | 18 +++++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/widget/src/mac/nsTextAreaWidget.cpp b/widget/src/mac/nsTextAreaWidget.cpp index e86fb1752c5c..51cba5e46ec5 100644 --- a/widget/src/mac/nsTextAreaWidget.cpp +++ b/widget/src/mac/nsTextAreaWidget.cpp @@ -237,8 +237,6 @@ PRBool nsTextAreaWidget::DispatchMouseEvent(nsMouseEvent &aEvent) //------------------------------------------------------------------------- PRBool nsTextAreaWidget::DispatchWindowEvent(nsGUIEvent &aEvent) { -#define enterKey 0x03 /* ascii code for enter key */ - // filter cursor keys PRBool passKeyEvent = PR_TRUE; switch (aEvent.message) @@ -246,14 +244,19 @@ PRBool nsTextAreaWidget::DispatchWindowEvent(nsGUIEvent &aEvent) case NS_KEY_DOWN: case NS_KEY_UP: { - // hack: if Enter is pressed, pass Return - nsKeyEvent* keyEvent = (nsKeyEvent*)&aEvent; - if (keyEvent->keyCode == enterKey) - keyEvent->keyCode = NS_VK_RETURN; + nsKeyEvent* keyEvent = (nsKeyEvent*)&aEvent; +#if 0 + // this hack is no longer needed, since Enter is being mapped to + // VK_RETURN in the event handler + if (keyEvent->keyCode == kEnterCharCode) + keyEvent->keyCode = NS_VK_RETURN; +#endif + + // is this hack really needed? EventRecord* theOSEvent = (EventRecord*)aEvent.nativeMsg; - if (theOSEvent && ((theOSEvent->message & charCodeMask) == enterKey)) - theOSEvent->message = (theOSEvent->message & ~charCodeMask) + NS_VK_RETURN; + if (theOSEvent && ((theOSEvent->message & charCodeMask) == kEnterCharCode)) + theOSEvent->message = (theOSEvent->message & ~charCodeMask) + kReturnCharCode; switch (keyEvent->keyCode) { @@ -318,7 +321,7 @@ PRBool nsTextAreaWidget::DispatchWindowEvent(nsGUIEvent &aEvent) else { nsKeyEvent* keyEvent = (nsKeyEvent*)&aEvent; - theChar = keyEvent->keyCode; + theChar = keyEvent->charCode; if (keyEvent->isShift) theModifiers = shiftKey; if (keyEvent->isControl) diff --git a/widget/src/mac/nsTextWidget.cpp b/widget/src/mac/nsTextWidget.cpp index 60807b63ad98..e4ebed566c24 100644 --- a/widget/src/mac/nsTextWidget.cpp +++ b/widget/src/mac/nsTextWidget.cpp @@ -168,8 +168,6 @@ PRBool nsTextWidget::DispatchMouseEvent(nsMouseEvent &aEvent) //------------------------------------------------------------------------- PRBool nsTextWidget::DispatchWindowEvent(nsGUIEvent &aEvent) { -#define enterKey 0x03 /* ascii code for enter key */ - // filter cursor keys PRBool passKeyEvent = PR_TRUE; switch (aEvent.message) @@ -178,13 +176,19 @@ PRBool nsTextWidget::DispatchWindowEvent(nsGUIEvent &aEvent) case NS_KEY_UP: { // hack: if Enter is pressed, pass Return - nsKeyEvent* keyEvent = (nsKeyEvent*)&aEvent; - if (keyEvent->keyCode == enterKey) - keyEvent->keyCode = NS_VK_RETURN; + nsKeyEvent* keyEvent = (nsKeyEvent*)&aEvent; +#if 0 + // this hack is no longer needed, since Enter is being mapped to + // VK_RETURN in the event handler + if (keyEvent->keyCode == kEnterCharCode) + keyEvent->keyCode = NS_VK_RETURN; +#endif + + // is this hack really needed? EventRecord* theOSEvent = (EventRecord*)aEvent.nativeMsg; - if (theOSEvent && ((theOSEvent->message & charCodeMask) == enterKey)) - theOSEvent->message = (theOSEvent->message & ~charCodeMask) + NS_VK_RETURN; + if (theOSEvent && ((theOSEvent->message & charCodeMask) == kEnterCharCode)) + theOSEvent->message = (theOSEvent->message & ~charCodeMask) + kReturnCharCode; switch (keyEvent->keyCode) {