Forum > LCL

[SOLVED] TBitBtn On Click not triggered

(1/7) > >>

incendio:
Hi guys,

I have TDBGrid and TBitBtn on a form.

Users can directly input/edit data on TDBGrid.

When cursor on TDBGrid is on Column Disc(Price) and users pressed ENTER key, I set codes to append dataset underlying TDBGrid and moved cursor to Column Code.

The display look like attachment SS1.png.

This the problem occurs, when users clicked Save button,  the display will turn into SS2.png and event click for that button was not triggered.

If I change TBitBtn to TEdit or TLabel, when users clicked this TEdit or TLabel, it worked as expected.

Can this problem with TBitbtn be solved?

bobby100:
There is something "fishy" about TBitBtn.
I also have some weird behavior here:
https://forum.lazarus.freepascal.org/index.php/topic,58357.msg445006.html#msg445006  (Problem Nr.1)
I suspect it has to do with ModalResult, but I don't know how to inspect it

jamie:
i guess a couple of question are in order.

 This is a Windows managed control which means the up/down and click are messaged pooled.

 Are you doing any code within the OnDown or OnUp messages of the button ?

 Those two events must property fire before a click event is seen. If for example you hide the control in the keyup event it could be possible that no click will ever arrive.
 The same is true for the Keydown etc.

  Graphic buttons are handled slightly different.

incendio:

--- Quote from: jamie on June 19, 2022, 02:59:46 pm ---i guess a couple of question are in order.

 This is a Windows managed control which means the up/down and click are messaged pooled.

 Are you doing any code within the OnDown or OnUp messages of the button ?

 Those two events must property fire before a click event is seen. If for example you hide the control in the keyup event it could be possible that no click will ever arrive.
 The same is true for the Keydown etc.

  Graphic buttons are handled slightly different.

--- End quote ---
TBitbtn only has codes in OnClick event.

I tried to add codes to OnKeyDown, this event also not triggered.

derek.john.evans:
How do you know the OnClick is not triggered? Try adding a fresh TBitBtn with a new OnClick event and confirm using ShowMessage('Clicked');

Have you tried a standard TButton? Again, try a fresh instance.

It looks looks like focus shifting is cancelling the append state for the TDataSet. Which is standard.

Without an example project, I can't offer much more, but, often if strange things are happening, I start commenting out code to bring some visible sanity back to a project.



Navigation

[0] Message Index

[#] Next page

Go to full version