From 762e5818d1c6cad877c3add809ef40c993478542 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Mon, 7 Jul 2008 11:04:06 -0400 Subject: [PATCH] richedit: Hide cursor when text is selected. The cursor should only be shown when there is no selection, since this is how it is done in Windows. This patch avoids showing the cursor when there is a selection, and destroys the cursor when a selection is made. --- dlls/riched20/caret.c | 16 ++++++++-------- dlls/riched20/editor.c | 6 +++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index b2dbd97d4ac..a76f2db9533 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -234,7 +234,7 @@ ME_MoveCaret(ME_TextEditor *editor) if (ME_WrapMarkedParagraphs(editor)) ME_UpdateScrollBar(editor); ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height); - if(editor->bHaveFocus) + if(editor->bHaveFocus && !ME_IsSelection(editor)) { RECT rect; @@ -242,6 +242,8 @@ ME_MoveCaret(ME_TextEditor *editor) x = min(x, rect.right-2); CreateCaret(editor->hWnd, NULL, 0, height); SetCaretPos(x, y); + } else { + DestroyCaret(); } } @@ -249,13 +251,13 @@ ME_MoveCaret(ME_TextEditor *editor) void ME_ShowCaret(ME_TextEditor *ed) { ME_MoveCaret(ed); - if(ed->bHaveFocus) + if(ed->bHaveFocus && !ME_IsSelection(ed)) ShowCaret(ed->hWnd); } void ME_HideCaret(ME_TextEditor *ed) { - if(ed->bHaveFocus) + if(!ed->bHaveFocus || ME_IsSelection(ed)) { HideCaret(ed->hWnd); DestroyCaret(); @@ -1038,8 +1040,7 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum) } ME_InvalidateSelection(editor); HideCaret(editor->hWnd); - ME_MoveCaret(editor); - ShowCaret(editor->hWnd); + ME_ShowCaret(editor); ME_ClearTempStyle(editor); ME_SendSelChange(editor); } @@ -1076,10 +1077,9 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y) SendMessageW(editor->hWnd, EM_SCROLLCARET, 0, 0); } - HideCaret(editor->hWnd); - ME_MoveCaret(editor); ME_InvalidateSelection(editor); - ShowCaret(editor->hWnd); + HideCaret(editor->hWnd); + ME_ShowCaret(editor); ME_SendSelChange(editor); } diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index e763090243b..7e900963ffe 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2195,6 +2195,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ME_InvalidateSelection(editor); ME_SetSelection(editor, wParam, lParam); ME_InvalidateSelection(editor); + HideCaret(editor->hWnd); + ME_ShowCaret(editor); ME_SendSelChange(editor); return 0; } @@ -2227,6 +2229,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ME_InvalidateSelection(editor); end = ME_SetSelection(editor, range.cpMin, range.cpMax); ME_InvalidateSelection(editor); + HideCaret(editor->hWnd); + ME_ShowCaret(editor); ME_SendSelChange(editor); return end; @@ -3096,8 +3100,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, return 0; case WM_KILLFOCUS: ME_CommitUndo(editor); /* End coalesced undos for typed characters */ - ME_HideCaret(editor); editor->bHaveFocus = FALSE; + ME_HideCaret(editor); ME_SendOldNotify(editor, EN_KILLFOCUS); return 0; case WM_ERASEBKGND: