Accept <Enter> for changing chat partner
authorH.G. Muller <h.g.muller@hccnet.nl>
Sat, 23 Jan 2010 20:44:36 +0000 (21:44 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Sat, 30 Jan 2010 08:46:23 +0000 (09:46 +0100)
A kludge stolen from Alessandro's GameList filter allowed to let the
typing of <Enter> while updating the chat-partner field of the WinBoard
chat windows to act as pressing the Change button. Gives focus to the
input field of the window afterwards.

winboard/wchat.c

index 363bebd..48d555a 100644 (file)
@@ -136,6 +136,7 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
     static SnapData sd;\r
     char buf[MSG_SIZ], mess[MSG_SIZ];\r
     int partner = -1, i;\r
+    static BOOL filterHasFocus[MAX_CHAT];\r
 \r
     for(i=0; i<MAX_CHAT; i++) if(hDlg == chatHandle[i]) { partner = i; break; }\r
 \r
@@ -148,10 +149,33 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
                SetWindowText(hDlg, buf);\r
         }\r
        chatPartner[partner][0] = 0;\r
+       filterHasFocus[partner] = FALSE;\r
 \r
         return FALSE;\r
 \r
     case WM_COMMAND:\r
+      /* \r
+        [AS]\r
+        If <Enter> is pressed while editing the filter, it's better to apply\r
+        the filter rather than selecting the current game.\r
+      */\r
+      if( LOWORD(wParam) == IDC_ChatPartner ) {\r
+          switch( HIWORD(wParam) ) {\r
+          case EN_SETFOCUS:\r
+              filterHasFocus[partner] = TRUE;\r
+              break;\r
+          case EN_KILLFOCUS:\r
+              filterHasFocus[partner] = FALSE;\r
+              break;\r
+          }\r
+      }\r
+\r
+      if( filterHasFocus[partner] && (LOWORD(wParam) == IDC_Send) ) {\r
+         SetFocus(GetDlgItem(hDlg, OPT_ChatInput));\r
+          wParam = IDC_Change;\r
+      }\r
+      /* [AS] End command replacement */\r
+\r
         switch (LOWORD(wParam)) {\r
 \r
        case IDCANCEL:\r