Recent

Author Topic: onmousedown event not registering correctly  (Read 6354 times)

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
onmousedown event not registering correctly
« on: July 21, 2016, 09:39:02 pm »
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?
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: onmousedown event not registering correctly
« Reply #1 on: July 21, 2016, 09:56:44 pm »
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.
« Last Edit: July 21, 2016, 09:58:35 pm by Handoko »

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: onmousedown event not registering correctly
« Reply #2 on: July 21, 2016, 11:21:10 pm »
The relevant piece of code is here
Code: Pascal  [Select][+][-]
  1. procedure TmainLazLock.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: integer);
  3. var
  4.   image: integer;
  5. begin
  6.   if ListView1.Selected <> nil then // Avoids error when a blank line is selected
  7.   begin
  8.     ResultName.Caption := ListView1.selected.SubItems[0];
  9.     ResultURL.Text := ListView1.selected.SubItems[1];
  10.     ResultUser.Text := ListView1.selected.SubItems[2];
  11.     ResultPassword.Text := ListView1.selected.SubItems[3];
  12.     image := StrToInt(ListView1.selected.SubItems[4]);
  13.     sitesImageList.GetBitmap(image, ResultImage.Picture.Bitmap);
  14.   end;
  15.   TBEditEntry.Enabled := True; // Allows selected entry to be edited
  16.   TBRemove.Enabled := True; // or deleted
  17.   mnuEdit.Enabled := True;  // Dropdown menu options
  18.   mnuDelete.Enabled := True;
  19. end;  

I originally used OnClick to update the display but switched to OnMouseDown so that it would work with the right-click menu.
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: onmousedown event not registering correctly
« Reply #3 on: July 21, 2016, 11:23:52 pm »
The full source code is here https://sourceforge.net/projects/lazlock/files/2.0.0.3/source/ in the unitmain.pas unit, line 664
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: onmousedown event not registering correctly
« Reply #4 on: July 21, 2016, 11:33:40 pm »
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...
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: onmousedown event not registering correctly
« Reply #5 on: July 22, 2016, 05:36:09 am »
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

  • Sr. Member
  • ****
  • Posts: 368
    • Windsurfer
Re: onmousedown event not registering correctly
« Reply #6 on: July 22, 2016, 10:28:19 am »
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

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: onmousedown event not registering correctly
« Reply #7 on: July 22, 2016, 11:56:25 am »
I'll see if I can compile it in QT later today then submit a bug report.
Thanks
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

Thaddy

  • Hero Member
  • *****
  • Posts: 14359
  • Sensorship about opinions does not belong here.
Re: onmousedown event not registering correctly
« Reply #8 on: July 22, 2016, 12:29:36 pm »
Unless the code involved indeed needs to track something while the mouse is down, use mouseUp instead.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: onmousedown event not registering correctly
« Reply #9 on: July 22, 2016, 06:49:53 pm »
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/
« Last Edit: July 22, 2016, 07:25:16 pm by CyberFilth »
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

 

TinyPortal © 2005-2018