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.
This commit is contained in:
Dylan Smith 2008-07-07 11:04:06 -04:00 committed by Alexandre Julliard
parent 69cf4e9ac4
commit 762e5818d1
2 changed files with 13 additions and 9 deletions

View File

@ -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);
}

View File

@ -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: