src/windows/native/sun/windows/awt_TextField.cpp

Print this page

        

@@ -73,10 +73,11 @@
 
 MsgRouting
 AwtTextField::HandleEvent(MSG *msg, BOOL synthetic)
 {
     MsgRouting returnVal;
+    BOOL systemBeeperEnabled = FALSE;
     /*
      * RichEdit 1.0 control starts internal message loop if the
      * left mouse button is pressed while the cursor is not over
      * the current selection or the current selection is empty.
      * Because of this we don't receive WM_MOUSEMOVE messages

@@ -215,19 +216,42 @@
             SendMessage(WM_HSCROLL,
                         MAKEWPARAM(SB_THUMBPOSITION, LOWORD(si.nPos)));
         }
         delete msg;
         return mrConsume;
+    } else if (msg->message == WM_KEYDOWN) {
+        UINT virtualKey = (UINT) msg->wParam;
+
+        switch(virtualKey){
+          case VK_RETURN:
+          case VK_UP:
+          case VK_DOWN:
+          case VK_LEFT:
+          case VK_RIGHT:
+          case VK_DELETE:
+          case VK_BACK:
+              SystemParametersInfo(SPI_GETBEEP, 0, &systemBeeperEnabled, 0);
+              if(systemBeeperEnabled){
+                  // disable system beeper for the RICHEDIT control to be compatible
+                  // with the EDIT control behaviour
+                  SystemParametersInfo(SPI_SETBEEP, 0, NULL, SPIF_UPDATEINIFILE);
+              }
+              break;
+          }
     }
     /*
      * Store the 'synthetic' parameter so that the WM_PASTE security check
      * happens only for synthetic events.
      */
     m_synthetic = synthetic;
     returnVal = AwtComponent::HandleEvent(msg, synthetic);
     m_synthetic = FALSE;
 
+    if(systemBeeperEnabled){
+      SystemParametersInfo(SPI_SETBEEP, 1, NULL, SPIF_UPDATEINIFILE);
+    }
+
     return returnVal;
 }
 
 void AwtTextField::_SetEchoChar(void *param)
 {