Recent

Author Topic: BGRA Button Controls - TBCButtonFocus  (Read 650 times)

dseligo

  • Full Member
  • ***
  • Posts: 231
BGRA Button Controls - TBCButtonFocus
« on: February 15, 2021, 02:47:53 pm »
I use TBCButtonFocus from BGRA Button Controls.
I noticed that if I call ShowMessage in button's OnClick event and press Enter key to close ShowMessage (or some other dialog, ShowMessage is just an example), OnClick event is fired again.

Is this a bug or a feature?

I attached example project that shows this behaviour.

lainz

  • Hero Member
  • *****
  • Posts: 4040
  • Leandro Diaz
Re: BGRA Button Controls - TBCButtonFocus
« Reply #1 on: February 16, 2021, 01:23:42 pm »
https://lainz.github.io/ - My Website :)
https://lazpaint.github.io/ -  Download LazPaint

dseligo

  • Full Member
  • ***
  • Posts: 231
Re: BGRA Button Controls - TBCButtonFocus
« Reply #2 on: February 16, 2021, 03:23:26 pm »
Thank you.

lainz

  • Hero Member
  • *****
  • Posts: 4040
  • Leandro Diaz
Re: BGRA Button Controls - TBCButtonFocus
« Reply #3 on: February 16, 2021, 04:45:14 pm »
It's strange, because the same code is used for spacebar and enter keys, and with spacebar there is no problem, it works fine.

Code: Pascal  [Select][+][-]
  1. procedure TCustomBCButtonFocus.KeyDown(var Key: word; Shift: TShiftState);
  2. begin
  3.   inherited KeyDown(Key, Shift);
  4.  
  5.   if (Key = VK_SPACE) or (Key = VK_RETURN) then
  6.     MouseDown(mbLeft, [], 0, 0);
  7. end;
  8.  
  9. procedure TCustomBCButtonFocus.KeyUp(var Key: word; Shift: TShiftState);
  10. begin
  11.   if (Key = VK_SPACE) or (Key = VK_RETURN) then
  12.   begin
  13.     MouseLeave;
  14.     Self.Click;
  15.   end;
  16.  
  17.   inherited KeyUp(Key, Shift);
  18. end;

Maybe there is some hidden LCL code that triggers the click again...
https://lainz.github.io/ - My Website :)
https://lazpaint.github.io/ -  Download LazPaint

 

TinyPortal © 2005-2018