Dylan Smith : richedit: Fixed double click issues by sharing code with single click.

Alexandre Julliard julliard at winehq.org
Mon Jul 7 09:19:23 CDT 2008


Module: wine
Branch: master
Commit: 5b2bdc06d00ef2a3e3bfd30dc142da5f902ede5b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5b2bdc06d00ef2a3e3bfd30dc142da5f902ede5b

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Sat Jul  5 04:23:53 2008 -0400

richedit: Fixed double click issues by sharing code with single click.

---

 dlls/riched20/caret.c  |   26 ++++++++++----------------
 dlls/riched20/editor.c |   14 ++++++--------
 dlls/riched20/editor.h |    2 +-
 3 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 4a79e48..c23d92c 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -749,8 +749,6 @@ ME_SelectWord(ME_TextEditor *editor)
   ME_MoveCursorWords(editor, &editor->pCursors[1], +1);
   editor->pCursors[0] = editor->pCursors[1];
   ME_MoveCursorWords(editor, &editor->pCursors[0], -1);
-  ME_InvalidateSelection(editor);
-  ME_SendSelChange(editor);
 }
 
 
@@ -871,7 +869,7 @@ ME_CharFromPos(ME_TextEditor *editor, int x, int y)
 }
 
 
-void ME_LButtonDown(ME_TextEditor *editor, int x, int y)
+void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
 {
   ME_Cursor tmp_cursor;
   int is_selection = 0;
@@ -888,19 +886,15 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y)
     ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd);
     if (GetKeyState(VK_SHIFT)>=0)
     {
+      /* Shift key is not down */
       editor->pCursors[1] = editor->pCursors[0];
+      if (clickNum > 1)
+          ME_SelectWord(editor);
     }
     else if (!is_selection) {
       editor->pCursors[1] = tmp_cursor;
       is_selection = 1;
     }
-
-    ME_InvalidateSelection(editor);
-    HideCaret(editor->hWnd);
-    ME_MoveCaret(editor);
-    ShowCaret(editor->hWnd);
-    ME_ClearTempStyle(editor);
-    ME_SendSelChange(editor);
   }
   else
   {
@@ -934,13 +928,13 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y)
     }
     editor->pCursors[2] = editor->pCursors[0];
     editor->pCursors[3] = editor->pCursors[1];
-    ME_InvalidateSelection(editor);
-    HideCaret(editor->hWnd);
-    ME_MoveCaret(editor);
-    ShowCaret(editor->hWnd);
-    ME_ClearTempStyle(editor);
-    ME_SendSelChange(editor);
   }
+  ME_InvalidateSelection(editor);
+  HideCaret(editor->hWnd);
+  ME_MoveCaret(editor);
+  ShowCaret(editor->hWnd);
+  ME_ClearTempStyle(editor);
+  ME_SendSelChange(editor);
 }
 
 void ME_MouseMove(ME_TextEditor *editor, int x, int y)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 6ff1385..2d00061 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2966,17 +2966,22 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
     ME_DestroyEditor(editor);
     SetWindowLongPtrW(hWnd, 0, 0);
     return 0;
+  case WM_LBUTTONDBLCLK:
   case WM_LBUTTONDOWN:
+  {
+    int clickNum = (msg == WM_LBUTTONDBLCLK) ? 2 : 1;
     ME_CommitUndo(editor); /* End coalesced undos for typed characters */
     if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
         !ME_FilterEvent(editor, msg, &wParam, &lParam))
       return 0;
     SetFocus(hWnd);
-    ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
+    ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam),
+                   clickNum);
     SetCapture(hWnd);
     ME_LinkNotify(editor,msg,wParam,lParam);
     if (!ME_SetCursor(editor, LOWORD(lParam))) goto do_default;
     break;
+  }
   case WM_MOUSEMOVE:
     if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
         !ME_FilterEvent(editor, msg, &wParam, &lParam))
@@ -3001,13 +3006,6 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
       if (!ret) goto do_default;
     }
     break;
-  case WM_LBUTTONDBLCLK:
-    if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
-        !ME_FilterEvent(editor, msg, &wParam, &lParam))
-      return 0;
-    ME_LinkNotify(editor,msg,wParam,lParam);
-    ME_SelectWord(editor);
-    break;
   case WM_RBUTTONUP:
   case WM_RBUTTONDOWN:
     ME_CommitUndo(editor); /* End coalesced undos for typed characters */
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 0fc615a..a23fb8b 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -181,7 +181,7 @@ void ME_HideCaret(ME_TextEditor *ed);
 void ME_ShowCaret(ME_TextEditor *ed);
 void ME_MoveCaret(ME_TextEditor *ed);
 int ME_CharFromPos(ME_TextEditor *editor, int x, int y);
-void ME_LButtonDown(ME_TextEditor *editor, int x, int y);
+void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum);
 void ME_MouseMove(ME_TextEditor *editor, int x, int y);
 void ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars);
 void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, 




More information about the wine-cvs mailing list