Lazarus

Installation => macOS / Mac OS X => Topic started by: ling on March 03, 2021, 08:12:05 am

Title: [SOLVED] TButton.OnMouseUp does not trigger
Post by: ling on March 03, 2021, 08:12:05 am
I bind an event to OnMouseUp for TButton, but when the button be clicked, only OnMouseDown and OnClick be triggered, is it a bug?

Lazarus version: 2.0.6
FPC: 3.0.4
macOS Catalina 10.15.7
Title: Re: TButton.OnMouseUp does not trigger
Post by: lucamar on March 03, 2021, 08:22:28 am
If you have properly set up events then yes, it looks like a bug, though it might be OS-specific behaviour; I don't know enough about Macos to even guess.

The "normal" chain of events is:
Title: Re: TButton.OnMouseUp does not trigger
Post by: Handoko on March 03, 2021, 08:36:21 am
It works on my Ubuntu Mate 20.10 Lazarus 2.0.10 GTK2.

I wrote a very simple demo to test it. Download and run my code, if it does not work on your computer, please report it to the bugtracker: https://bugs.freepascal.org/view_all_bug_page.php?project_id=1

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
  17.       Shift: TShiftState; X, Y: Integer);
  18.     procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;
  19.       Shift: TShiftState; X, Y: Integer);
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.lfm}
  28.  
  29. { TForm1 }
  30.  
  31. procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  32.   Shift: TShiftState; X, Y: Integer);
  33. begin
  34.   Button1.Caption := 'MouseDown event triggered';
  35. end;
  36.  
  37. procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;
  38.   Shift: TShiftState; X, Y: Integer);
  39. begin
  40.   Button1.Caption := 'MouseUp event triggered';
  41. end;
  42.  
  43. end.
Title: Re: TButton.OnMouseUp does not trigger
Post by: ling on March 03, 2021, 10:07:10 am
@Handoko Thanks for your demo code. I've tried it, mouse up doesn't trigger.

Title: Re: TButton.OnMouseUp does not trigger
Post by: trev on March 03, 2021, 10:15:44 am
It works in macOS 10.14 with Lazarus trunk and FPC 3.0.4 or 3.2.0 or trunk.

Looks like it was fixed in Lazarus 2.0.8 - the OP needs to upgrade! See Bug #38099 (https://bugs.freepascal.org/view.php?id=38099).

I just confirmed that it works in Lazarus 2.0.10 with FPC 3.2.0.
Title: Re: [SOLVED] TButton.OnMouseUp does not trigger
Post by: ling on March 16, 2021, 02:42:43 pm
@trev Thanks,

I updated lazarus and fpc to the latest version, it works fine now.
TinyPortal © 2005-2018