Recent

Author Topic: TBCMaterialDesignButton.Click is not public  (Read 1228 times)

alpine

  • Hero Member
  • *****
  • Posts: 1316
TBCMaterialDesignButton.Click is not public
« on: February 16, 2024, 03:24:16 pm »
I've replaced a TButton with TBCMaterialDesignButton and noticed that I can't .Click it.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

lainz

  • Hero Member
  • *****
  • Posts: 4651
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: TBCMaterialDesignButton.Click is not public
« Reply #1 on: February 16, 2024, 05:40:59 pm »
I've replaced a TButton with TBCMaterialDesignButton and noticed that I can't .Click it.

Just call the method

Code: Pascal  [Select][+][-]
  1. BCMaterialDesignButton1Click(nil);

For now, and report in BGRAControls issues at GitHub, here will be lost and not fixed.

alpine

  • Hero Member
  • *****
  • Posts: 1316
Re: TBCMaterialDesignButton.Click is not public
« Reply #2 on: February 16, 2024, 06:47:28 pm »
I've replaced a TButton with TBCMaterialDesignButton and noticed that I can't .Click it.

Just call the method

Code: Pascal  [Select][+][-]
  1. BCMaterialDesignButton1Click(nil);

For now, and report in BGRAControls issues at GitHub, here will be lost and not fixed.
Will it show its fancy animation then?

"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

lainz

  • Hero Member
  • *****
  • Posts: 4651
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: TBCMaterialDesignButton.Click is not public
« Reply #3 on: February 16, 2024, 06:51:25 pm »
I've replaced a TButton with TBCMaterialDesignButton and noticed that I can't .Click it.

Just call the method

Code: Pascal  [Select][+][-]
  1. BCMaterialDesignButton1Click(nil);

For now, and report in BGRAControls issues at GitHub, here will be lost and not fixed.
Will it show its fancy animation then?

Depends, if I can create that or not, I don't know util I grab the code and try to implement that.

Bart

  • Hero Member
  • *****
  • Posts: 5496
    • Bart en Mariska's Webstek
Re: TBCMaterialDesignButton.Click is not public
« Reply #4 on: February 16, 2024, 06:54:06 pm »
Will it show its fancy animation then?
No. it will just execute the oncick handler.
Does Click actually implement the fancy animation?
E.g. TButton.Click doen's make the button perform it "click animation".

Bart

alpine

  • Hero Member
  • *****
  • Posts: 1316
Re: TBCMaterialDesignButton.Click is not public
« Reply #5 on: February 17, 2024, 11:08:26 pm »
Will it show its fancy animation then?
No. it will just execute the oncick handler.
Does Click actually implement the fancy animation?
E.g. TButton.Click doen's make the button perform it "click animation".

Bart
That's right.

But what I wanted is to replace the TButton's with TBCMaterialDesignButton's which are more appealing visually. Because it is into a visual keypad form (was fully working with TButton's) I wanted buttons to be clicked by pressing a digit keys from a keyboard: but no public Click method. Then it turns out there is no Default property to set in 'Done' button when enough digits entered, etc.

The animation would be a bonus, but it's not the most important one. The thing is that the TBCMaterialDesignButton isn't the most consistent button control, it lacks many of the properties of the regular TButton.

I wanted to point this out.

Of course, I know how to overcome the current shortcomings, the easiest way is with a class helper visibility hack:

Code: Pascal  [Select][+][-]
  1.   TBCMaterialDesignButtonHelp = class helper for TBCMaterialDesignButton
  2.   private
  3.     function GetDefault: Boolean; // GetParentForm(Self).DefaultControl = Self
  4.     procedure SetDefault(AValue: Boolean); // GetParentForm(Self).DefaultControl := Self/Nil
  5.   public
  6.     procedure ClickMe; // calls Click
  7.     property Default: Boolean read GetDefault write SetDefault default False;
  8.   end;
  9.  
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

lainz

  • Hero Member
  • *****
  • Posts: 4651
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: TBCMaterialDesignButton.Click is not public
« Reply #6 on: February 18, 2024, 12:08:06 am »
Hi, I've added click procedure with animation on dev-bgracontrols branch.
https://github.com/bgrabitmap/bgracontrols/tree/dev-bgracontrols

Edit:
I've changed the procedure name to ClickMe, because if I use Click it interferes with default Click with mouse...

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
  2. begin
  3.   BCMaterialDesignButton1.ClickMe;
  4. end;
  5.  
  6. procedure TForm1.BCMaterialDesignButton1Click(Sender: TObject);
  7. begin
  8.   ShowMessage('ok');
  9. end;
« Last Edit: February 18, 2024, 12:24:03 am by lainz »

alpine

  • Hero Member
  • *****
  • Posts: 1316
Re: TBCMaterialDesignButton.Click is not public
« Reply #7 on: February 19, 2024, 09:08:51 am »
@lainz
Thanks.

IMHO it will be good to put the Click into the public section and to implement the Default property as  sketched into the class helper. The Click method deals also with the Action when it is attached, and it is an useful feature.

"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

 

TinyPortal © 2005-2018