Recent

Author Topic: [SOLVED] TBitBtn On Click not triggered  (Read 1446 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 11774
Re: TBitBtn On Click not triggered
« Reply #30 on: June 22, 2022, 02:24:02 pm »
OnKeyDown needs to execute as much as possible, because it needs to maintain state.
It is often misused and misunderstood.
Usually it can be replaced with OnKeyUp which is a real single fire event.

So no wonder OnKeyDown has more code... It should have more.....

Not understanding the difference between the two is a very common design flaw.

E.g. with ctrl--<arrow keys> to navigate, OnKeyDown is the option. Otherwise use OnKeyUp.
LCL is literaly littered with that mistake. Even Delphi has a couple of issues, but far less so.
« Last Edit: June 22, 2022, 02:41:52 pm by Thaddy »
Black themes should be banned.

Handoko

  • Hero Member
  • *****
  • Posts: 4690
  • My goal: build my own game engine using Lazarus
Re: TBitBtn On Click not triggered
« Reply #31 on: June 22, 2022, 05:05:57 pm »
1. Did you experience the same problem with mine, that OnClick event is not triggered on TBitBtn?
Yes.

I didn't have that problem, it worked correctly on Linux. Here I created a short video:

https://imgur.com/a/n6qtAPJ

(Because of the limitation of uploaded file size here, I have to use online file sharing service).

dseligo

  • Hero Member
  • *****
  • Posts: 651
Re: TBitBtn On Click not triggered
« Reply #32 on: June 22, 2022, 09:32:11 pm »
1. Did you experience the same problem with mine, that OnClick event is not triggered on TBitBtn?
Yes.

I didn't have that problem, it worked correctly on Linux. Here I created a short video:

https://imgur.com/a/n6qtAPJ

(Because of the limitation of uploaded file size here, I have to use online file sharing service).

Since on Windows works differently than you posted I'd say it's definitely a bug.

dseligo

  • Hero Member
  • *****
  • Posts: 651
Re: TBitBtn On Click not triggered
« Reply #33 on: June 22, 2022, 09:37:10 pm »
Well, maybe my description is not correct, it's a very complicated flow of events. Following the keypress with the debugger I saw that further code is executed after the OnKeyDown handler. Probably this should not be done, and I had the idea to "eat" the RETURN key by inserting "Key := 0" after "Qry.Append" - now the OnClick events of the Button and BitBtn are fired correctly.

This is interesting. But why some controls (TEdit and TBCButtonFocus, e.g.) works without it, and others needs 'Key := 0'?

incendio

  • Full Member
  • ***
  • Posts: 175
Re: TBitBtn On Click not triggered
« Reply #34 on: June 23, 2022, 04:17:32 am »
Well, maybe my description is not correct, it's a very complicated flow of events. Following the keypress with the debugger I saw that further code is executed after the OnKeyDown handler. Probably this should not be done, and I had the idea to "eat" the RETURN key by inserting "Key := 0" after "Qry.Append" - now the OnClick events of the Button and BitBtn are fired correctly.

I choose this method to solve the problem  :D

Since on Windows works differently than you posted I'd say it's definitely a bug.

Agreed. I will make a bug report.

 

TinyPortal © 2005-2018