onDblClick on TMemo and TEdit glitch. lazarus / 31-LCL ---------------------------------------------------------------------- Ñuño_Martínez · 2014-09-30 12:57 So, I have a TMemo, and I created an onDblClick event for it.  The event opens a modal dialog.  Problem is that when the modal dialog closes, the TMemo still tracks the mouse as it was selecting text.  That's quite annoying.  I wonder if I'm missing something or there's a workaround. To reproduce the problem, just create a new project, add a TMemo to the form and set its double click event to this: Code: [Select]PROCEDURE TForm1.Memo1DblClick (Sender: TObject); BEGIN   MessageDlg ('Info', 'This will be weird!', mtInformation, [mbIgnore], 0) END; Now, if you doubleclick the memo, you'll see the message dialog, and after closing move the mouse over the memo without clicking.  You'll see you're selecting the text! The glitch works on Linux + GTK (Fedora). ---------------------------------------------------------------------- Bart · 2014-09-30 14:27 Which Lazarus version? If it happens in trunk, please open a ticket in the bugtracker (and attach a compilable project). Bart ---------------------------------------------------------------------- derek.john.evans · 2014-09-30 15:58 Here is a workaround that will leave the cursor under the double clicked point. It stores the SelStart in OnClick, and then restores it if there is a DblClick. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFormMain.MemoClick(Sender: TObject);begin  FSelStart := Memo.SelStart;end; procedure TFormMain.MemoDblClick(Sender: TObject);begin  Memo.SelStart := FSelStart;  ShowMessage('Double Click');end; ---------------------------------------------------------------------- derek.john.evans · 2014-09-30 16:06 Sorry for the double post. Another idea: Keep a copy of the current selection via a OnMouseMove, then you can restore the actual selection before a double click. There may be some side effects. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFormMain.MemoDblClick(Sender: TObject);begin  Memo.SelStart := FSelStart;  Memo.SelLength := FSelLength;  ShowMessage('Double Click');end; procedure TFormMain.MemoMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);begin  FSelStart := Memo.SelStart;  FSelLength := Memo.SelLength;end; ---------------------------------------------------------------------- Ñuño_Martínez · 2014-10-01 07:21 Quote from: Bart on September 30, 2014, 04:27:03 pmWhich Lazarus version? The one that came with Fedora 20 - Lazarus 1.0.8  Quote from: derek.john.evans on September 30, 2014, 05:58:11 pmHere is a workaround that will leave the cursor under the double clicked point. It stores the SelStart in OnClick, and then restores it if there is a DblClick.It doesn't work.  The problem is that the control "thinks" that user is still pressing the mouse button. ---------------------------------------------------------------------- rumen-lazarus · 2014-10-01 13:23 My workaround is: Code: [Select]procedure TFormMain.MemoDblClick(Sender: TObject); begin   Application.QueueAsyncCall( acMemoDblClick,PtrInt(Sender)); end; This is not ideal, but ...