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:
parent
69cf4e9ac4
commit
762e5818d1
|
@ -234,7 +234,7 @@ ME_MoveCaret(ME_TextEditor *editor)
|
||||||
if (ME_WrapMarkedParagraphs(editor))
|
if (ME_WrapMarkedParagraphs(editor))
|
||||||
ME_UpdateScrollBar(editor);
|
ME_UpdateScrollBar(editor);
|
||||||
ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
|
ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
|
||||||
if(editor->bHaveFocus)
|
if(editor->bHaveFocus && !ME_IsSelection(editor))
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
|
@ -242,6 +242,8 @@ ME_MoveCaret(ME_TextEditor *editor)
|
||||||
x = min(x, rect.right-2);
|
x = min(x, rect.right-2);
|
||||||
CreateCaret(editor->hWnd, NULL, 0, height);
|
CreateCaret(editor->hWnd, NULL, 0, height);
|
||||||
SetCaretPos(x, y);
|
SetCaretPos(x, y);
|
||||||
|
} else {
|
||||||
|
DestroyCaret();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,13 +251,13 @@ ME_MoveCaret(ME_TextEditor *editor)
|
||||||
void ME_ShowCaret(ME_TextEditor *ed)
|
void ME_ShowCaret(ME_TextEditor *ed)
|
||||||
{
|
{
|
||||||
ME_MoveCaret(ed);
|
ME_MoveCaret(ed);
|
||||||
if(ed->bHaveFocus)
|
if(ed->bHaveFocus && !ME_IsSelection(ed))
|
||||||
ShowCaret(ed->hWnd);
|
ShowCaret(ed->hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ME_HideCaret(ME_TextEditor *ed)
|
void ME_HideCaret(ME_TextEditor *ed)
|
||||||
{
|
{
|
||||||
if(ed->bHaveFocus)
|
if(!ed->bHaveFocus || ME_IsSelection(ed))
|
||||||
{
|
{
|
||||||
HideCaret(ed->hWnd);
|
HideCaret(ed->hWnd);
|
||||||
DestroyCaret();
|
DestroyCaret();
|
||||||
|
@ -1038,8 +1040,7 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
|
||||||
}
|
}
|
||||||
ME_InvalidateSelection(editor);
|
ME_InvalidateSelection(editor);
|
||||||
HideCaret(editor->hWnd);
|
HideCaret(editor->hWnd);
|
||||||
ME_MoveCaret(editor);
|
ME_ShowCaret(editor);
|
||||||
ShowCaret(editor->hWnd);
|
|
||||||
ME_ClearTempStyle(editor);
|
ME_ClearTempStyle(editor);
|
||||||
ME_SendSelChange(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);
|
SendMessageW(editor->hWnd, EM_SCROLLCARET, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
HideCaret(editor->hWnd);
|
|
||||||
ME_MoveCaret(editor);
|
|
||||||
ME_InvalidateSelection(editor);
|
ME_InvalidateSelection(editor);
|
||||||
ShowCaret(editor->hWnd);
|
HideCaret(editor->hWnd);
|
||||||
|
ME_ShowCaret(editor);
|
||||||
ME_SendSelChange(editor);
|
ME_SendSelChange(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2195,6 +2195,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
|
||||||
ME_InvalidateSelection(editor);
|
ME_InvalidateSelection(editor);
|
||||||
ME_SetSelection(editor, wParam, lParam);
|
ME_SetSelection(editor, wParam, lParam);
|
||||||
ME_InvalidateSelection(editor);
|
ME_InvalidateSelection(editor);
|
||||||
|
HideCaret(editor->hWnd);
|
||||||
|
ME_ShowCaret(editor);
|
||||||
ME_SendSelChange(editor);
|
ME_SendSelChange(editor);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2227,6 +2229,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
|
||||||
ME_InvalidateSelection(editor);
|
ME_InvalidateSelection(editor);
|
||||||
end = ME_SetSelection(editor, range.cpMin, range.cpMax);
|
end = ME_SetSelection(editor, range.cpMin, range.cpMax);
|
||||||
ME_InvalidateSelection(editor);
|
ME_InvalidateSelection(editor);
|
||||||
|
HideCaret(editor->hWnd);
|
||||||
|
ME_ShowCaret(editor);
|
||||||
ME_SendSelChange(editor);
|
ME_SendSelChange(editor);
|
||||||
|
|
||||||
return end;
|
return end;
|
||||||
|
@ -3096,8 +3100,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
|
||||||
return 0;
|
return 0;
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
ME_CommitUndo(editor); /* End coalesced undos for typed characters */
|
ME_CommitUndo(editor); /* End coalesced undos for typed characters */
|
||||||
ME_HideCaret(editor);
|
|
||||||
editor->bHaveFocus = FALSE;
|
editor->bHaveFocus = FALSE;
|
||||||
|
ME_HideCaret(editor);
|
||||||
ME_SendOldNotify(editor, EN_KILLFOCUS);
|
ME_SendOldNotify(editor, EN_KILLFOCUS);
|
||||||
return 0;
|
return 0;
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
|
|
Loading…
Reference in New Issue