Recent

Author Topic: [SOLVED] TButton.OnMouseUp does not trigger  (Read 1655 times)

ling

  • New Member
  • *
  • Posts: 14
[SOLVED] TButton.OnMouseUp does not trigger
« 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
« Last Edit: March 16, 2021, 03:14:06 am by ling »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: TButton.OnMouseUp does not trigger
« Reply #1 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:
  • MouseDown,
  • MouseUp,
  • Click
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Handoko

  • Hero Member
  • *****
  • Posts: 4327
  • My goal: build my own game engine using Lazarus
Re: TButton.OnMouseUp does not trigger
« Reply #2 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.

ling

  • New Member
  • *
  • Posts: 14
Re: TButton.OnMouseUp does not trigger
« Reply #3 on: March 03, 2021, 10:07:10 am »
@Handoko Thanks for your demo code. I've tried it, mouse up doesn't trigger.


trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1584
  • Former Delphi 1-7, 10.2 user
Re: TButton.OnMouseUp does not trigger
« Reply #4 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.

I just confirmed that it works in Lazarus 2.0.10 with FPC 3.2.0.
« Last Edit: March 03, 2021, 10:35:08 am by trev »
Lazarus 2.3 2021-08-10 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.3 r65500 FPC 3.3.1 r49634 macOS 11.5.2 aarch64 Xcode 12.5.1
Lazarus 2.3 2021-08-11 FPC 3.2.2 FreeBSD 13.0 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

ling

  • New Member
  • *
  • Posts: 14
Re: [SOLVED] TButton.OnMouseUp does not trigger
« Reply #5 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