richedit: Fixed double click issues by sharing code with single click.
This commit is contained in:
parent
379835b634
commit
5b2bdc06d0
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue