OK... once again, I think I have it worked out and fixed the problem I was having. Below is the revised code:
First I added a new Boolean (added just under _FAfterTextObjectClick):
_FAfterDblClick: Boolean;
Then the two updated routines:
procedure TWPCustomRtfEdit.DblClick;var vIgnore: Boolean; vTextObj: TWPTextObj;begin if FLastMouseWasDrag or FInMouseDown or _3rdParty_MouseLock then exit; _FAfterDblClick := TRUE; if assigned(FOnTextObjectDblClick) then begin if FTextObjectUnderMouse <> nil then vTextObj := FTextObjectUnderMouse else if not CodeObjectAtXY(FClientMouseX, FClientMouseY, vTextObj) then vTextObj := nil; if (vTextObj <> nil) and not (FLastMovedObject = vTextObj) then begin vIgnore := FALSE; FOnTextObjectDblClick(Self, vTextObj, vTextObj.ObjRef, vIgnore); if vIgnore then exit; HideSelection; RePaint; end; end; FLastMovedObject := nil; DoDblClick(MousePage, FMouseX, FMouseY); if not (wpDisableSelection in EditoptionsEx) then StartUpdate(WPUPD_UPDSELECTION);end;procedure TWPCustomRtfEdit.Click;var vMaxTickCount, vDblClickTime: DWord; vIsDblClick, vIgnore: Boolean; vTextObj: TWPTextObj; vMsg: Windows.TMsg; vScreenCP, vClientCP: TPoint; vHideSelection: Boolean; vPar: TParagraph; vPosInPar: Integer;begin if FLastMouseWasDrag or FInMouseDown or _3rdParty_MouseLock then exit; vIsDblClick := FALSE; vIgnore := FALSE; vScreenCP := Mouse.CursorPos; vClientCP := ScreenToClient(vScreenCP); vHideSelection := (GetAsyncKeyState(FVKLeftMouseButton) >= 0); { We need to check if we are at selection to make triple click possible } if not (wpDisableSelection in EditOptionsEx) and vHideSelection and TextCursor.IsSelected(false) and not GetLineFromXY(vClientCP.x, vClientCP.y, vPar, vPosInPar) and not FMemo.Cursor.IsTextSelected(vPar, vPosInPar) and (FTextObjectUnderMouse = nil) //V5.22.1 then begin HideSelection; RePaint; vHideSelection := FALSE; end; // Now check for KeyPress and DblClick events to abort loop at once vDblClickTime := GetDoubleClickTime(); if vDblClickTime > 200 then vDblClickTime := 200; // Typical DoubleClickTime=500ms, causes LONG delay! vMaxTickCount := GetTickCount + vDblClickTime; while (not vIsDblClick) and (not vIgnore) and (GetTickCount < vMaxTickCount) do begin if PeekMessage(vMsg, Handle, WM_LBUTTONDBLCLK, WM_LBUTTONDBLCLK, PM_NOREMOVE) then vIsDblClick := TRUE else if PeekMessage(vMsg, Handle, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE) then vIgnore := TRUE; end; if (GetAsyncKeyState(FVKLeftMouseButton) >= 0) then vHideSelection := TRUE; // Left mouse button is not down if vIsDblClick then exit; if (vHideSelection) //V5.22 Mouse Up! and (not (wpDisableSelection in EditOptionsEx)) and (IsSelected) and (FTextObjectUnderMouse = nil) and (FMouseSelectCell = nil) and ((FMouseClickFrameBorder * [wpClickLeftMargin, wpClickRightMargin]) = []) then begin HideSelection; RePaint; end; if assigned(FOnTextObjectClick) then begin if FTextObjectUnderMouse <> nil then vTextObj := FTextObjectUnderMouse else if not CodeObjectAtXY(FClientMouseX, FClientMouseY, vTextObj) then vTextObj := nil; if (vTextObj <> nil) and not (FLastMovedObject = vTextObj) then begin vIgnore := FALSE; FOnTextObjectClick(Self, vTextObj, vTextObj.ObjRef, vIgnore); if vIgnore then begin _FAfterTextObjectClick := TRUE; exit; end; end; end; FLastMovedObject := nil; if Memo.HasData then begin if not (wpDisableSelection in EditoptionsEx) and (GetTickCount > FLastSelectionChange) and (GetAsyncKeyState(FVKLeftMouseButton) > 0) and not (SelectedObject <> nil) and (FMouseSelectCell = nil) then HideSelection; DoClickPage(MousePage); if FMemo._HasSelectionPaint then StartUpdate(WPUPD_REPAINT); DoClick(MousePage, FMouseX, FMouseY); end; if not (wpDisableSelection in EditoptionsEx) then StartUpdate(WPUPD_UPDSELECTION);end;
Plus added this to the beginning of TWPCustomRtfEdit.MouseDown because a control's WMLButtonDblClk event calls DoMouseDown:
if _FAfterDblClick then
begin
_FAfterDblClick := false;
exit;
end;
I'll keep you posted should I run into more issues.