onmousedown event not registering correctly lazarus / 1-Linux ---------------------------------------------------------------------- CyberFilth · 2016-07-21 19:39 I've recently made an application in Windows that compiles fine but the Linux version is causing me issues. The source and binaries are here https://sourceforge.net/projects/lazlock/files/2.0.0.3/ The TListView on the top right updates the display when left-clicked, using an OnMouseDown event. On Linux you need to double-click to trigger the same event. I've compiled it under 32 bit Bunsen Labs and 64 bit Lubuntu and the behaviour is the same. The Windows 32 & 64 bit binaries work correctly with just a single click however. Does anyone have an idea why the Linux versions aren't working correctly? ---------------------------------------------------------------------- Handoko · 2016-07-21 19:56 I downloaded and tested your program. I confirm it happens on my Ubuntu Mate 64-bit. Without looking into your code, nothing much we can say. Can you share your code? A stripped-down version or a short demo is okay. I ever have mouse event issue which I think is similar to yours. If I'm not wrong, I fixed (?) it by adding some more events to detect the mouse behavior. ---------------------------------------------------------------------- CyberFilth · 2016-07-21 21:21 The relevant piece of code is here 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 TmainLazLock.ListView1MouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: integer);var  image: integer;begin  if ListView1.Selected <> nil then // Avoids error when a blank line is selected  begin    ResultName.Caption := ListView1.selected.SubItems[0];    ResultURL.Text := ListView1.selected.SubItems[1];    ResultUser.Text := ListView1.selected.SubItems[2];    ResultPassword.Text := ListView1.selected.SubItems[3];    image := StrToInt(ListView1.selected.SubItems[4]);    sitesImageList.GetBitmap(image, ResultImage.Picture.Bitmap);  end;  TBEditEntry.Enabled := True; // Allows selected entry to be edited  TBRemove.Enabled := True; // or deleted  mnuEdit.Enabled := True;  // Dropdown menu options  mnuDelete.Enabled := True;end;   I originally used OnClick to update the display but switched to OnMouseDown so that it would work with the right-click menu. ---------------------------------------------------------------------- CyberFilth · 2016-07-21 21:23 The full source code is here https://sourceforge.net/projects/lazlock/files/2.0.0.3/source/ in the unitmain.pas unit, line 664 ---------------------------------------------------------------------- CyberFilth · 2016-07-21 21:33 I tried your idea of adding more events and including an OnSelectItem fixes the left click issue. Only a single click is now needed. It doesn't solve the right click menu however. That still needs to be double-clicked... ---------------------------------------------------------------------- Handoko · 2016-07-22 03:36 Although, I can't open the the .lfm to check the component properties (you haven't provide all the files for security reasons). But from the code you provided, I didn't find anything wrong in your code. You may submit a bug report to here: http://bugs.freepascal.org/my_view_page.php ---------------------------------------------------------------------- Windsurfer · 2016-07-22 08:28 I have problems detecting some key presses in Linux when using GTK. I read somewhere recently that it may be fixed in GTK 3 or 5. I can't remember which. If you change to QT the problems may be solved, but you will have to accept the different appearance. I use Linux Mint 17.3 Cinnamon. ---------------------------------------------------------------------- CyberFilth · 2016-07-22 09:56 I'll see if I can compile it in QT later today then submit a bug report. Thanks ---------------------------------------------------------------------- Thaddy · 2016-07-22 10:29 Unless the code involved indeed needs to track something while the mouse is down, use mouseUp instead. ---------------------------------------------------------------------- CyberFilth · 2016-07-22 16:49 Adding an OnMouseUp event didn't change anything but compiling it with a QT interface works perfectly! Thanks to all of you for the suggestions. The binaries are here https://sourceforge.net/projects/lazlock/files/2.0.1.0/