Recent

Author Topic: [SOLVED] BGRAControls (BCButton)  (Read 4827 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
[SOLVED] BGRAControls (BCButton)
« on: May 31, 2021, 05:12:32 pm »
I like BGRAControls. but one thing annoys me.

At design time double clicking a BCButton brings up the Assign Theme dialog, which is probably used once, in stead of creating the OnClick event which is probably needed many times.
How / where can I change this action?
« Last Edit: June 02, 2021, 02:51:04 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/
Re: BGRAControls (BCButton)
« Reply #1 on: June 01, 2021, 09:39:15 am »
Good question. Like a button theme is his clothes and need to change clothes style too often instead of behavior (in dev mode). It has sense if you want to try things like if your app will have multiple themes and you want to preview them (in dev mode).

But usually that's tested at runtime instead. Styles on dev mode are just like wysiwyg.

Or I'm missing something?

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: BGRAControls (BCButton)
« Reply #2 on: June 01, 2021, 10:02:11 am »
Yes, but once you have a style you keep it and don't change it whereas in dev mode code is always changing.

Do you know where I start looking to make this change? (If only for myself)

Edit: I'll probably get slammed for this, but that's the female way of thinking. They know the color, and don't care about functionality. Sorry ladies.
« Last Edit: June 01, 2021, 10:35:16 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

dseligo

  • Hero Member
  • *****
  • Posts: 1222
Re: BGRAControls (BCButton)
« Reply #3 on: June 01, 2021, 10:43:59 am »
Yes, but once you have a style you keep it and don't change it whereas in dev mode code is always changing.

I agree. I set same style for all buttons in code when creating form, but (almost) every button has it's own OnClick event.
But, maybe I am not typical user.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: BGRAControls (BCButton)
« Reply #4 on: June 01, 2021, 10:58:17 am »
That's exactly my point.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/
Re: BGRAControls (BCButton)
« Reply #5 on: June 01, 2021, 01:24:34 pm »
I will change it to be standard. I'm not the author of that control but I think he or she had his reason to make it that way.

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/
Re: BGRAControls (BCButton)
« Reply #6 on: June 01, 2021, 02:10:52 pm »
Anyways I will need a bit of help, the file is BCStylesForm.pas

In that file

Code: Pascal  [Select][+][-]
  1. procedure TBCStyleComponentEditor.ExecuteVerb(Index: Integer);
  2. begin
  3.   case Index of
  4.     0: DoShowEditor;
  5.   end;
  6. end;
  7.  
  8. function TBCStyleComponentEditor.GetVerb(Index: Integer): String;
  9. begin
  10.   Result := 'Assign style';
  11. end;
  12.  
  13. function TBCStyleComponentEditor.GetVerbCount: Integer;
  14. begin
  15.   Result := 1;
  16. end;

I think if you just remove that, it will work.

But I think that menu entry should be optional and not removed, and add the default the OnClick event. But I'm not sure on how to do that.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: BGRAControls (BCButton)
« Reply #7 on: June 01, 2021, 03:18:02 pm »
OK,

I changed to this

Code: Pascal  [Select][+][-]
  1. procedure TBCStyleComponentEditor.ExecuteVerb(Index: Integer);
  2. begin
  3.   //case Index of
  4.     //0: DoShowEditor;
  5. end;
  6.  
  7. function TBCStyleComponentEditor.GetVerb(Index: Integer): String;
  8. begin
  9.   //Result := 'Assign style';
  10. end;
  11.  
  12. function TBCStyleComponentEditor.GetVerbCount: Integer;
  13. begin
  14.   //Result := 1;
  15. end;

and that stopped dblclicking from showing the dialog from showing, but it should instead create the OnClick event, and it doesn't.
DblClicking crashes the IDE.
Any ideas?
« Last Edit: June 01, 2021, 03:45:31 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/
Re: BGRAControls (BCButton)
« Reply #8 on: June 01, 2021, 04:05:14 pm »
Unregister that menu?

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: BGRAControls (BCButton)
« Reply #9 on: June 01, 2021, 04:36:53 pm »
To preserve functionality these lines must remain unchanged

Code: Pascal  [Select][+][-]
  1. function TBCStyleComponentEditor.GetVerb(Index: Integer): String;
  2. begin
  3.   Result := 'Assign style';
  4. end;
  5.  
  6. function TBCStyleComponentEditor.GetVerbCount: Integer;
  7. begin
  8.   Result := 1;
  9. end;
  10.  

Just need to figure out what to do here

Code: Pascal  [Select][+][-]
  1. procedure TBCStyleComponentEditor.ExecuteVerb(Index: Integer);
  2. begin
  3.   case Index of
  4.     0: ;//DoShowEditor;
  5.   end;
  6. end;
  7.  
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: BGRAControls (BCButton)
« Reply #10 on: June 01, 2021, 05:11:46 pm »
This works

Code: Pascal  [Select][+][-]
  1. initialization
  2.   //RegisterComponentEditor(TBCStyleGraphicControl, TBCStyleComponentEditor);
  3.   //RegisterComponentEditor(TBCStyleCustomControl, TBCStyleComponentEditor);
  4.   {$IFDEF FPC}
  5.   //RegisterPropertyEditor(ClassTypeInfo(TBCStyleDummyProperty),nil,'',TBCSylePropertyEditor);
  6.   {$ELSE}
  7.   RegisterPropertyEditor(TypeInfo(TBCStyleDummyProperty),nil,'',TBCSylePropertyEditor);
  8.   {$ENDIF}
  9.  
  10. procedure TBCStyleComponentEditor.ExecuteVerb(Index: Integer);
  11. begin
  12.   case Index of
  13.     0: DoShowEditor;
  14.   end;
  15. end;      
  16.  

Thanks for your help.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/
Re: BGRAControls (BCButton)
« Reply #11 on: June 01, 2021, 06:42:44 pm »
You're welcome  :)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: BGRAControls (BCButton)
« Reply #12 on: June 02, 2021, 02:50:07 am »
If anyone is interested it's very easy to change the default style. Edit bcbutton.pas. Change

Code: Pascal  [Select][+][-]
  1. procedure TCustomBCButton.AssignDefaultStyle;
  2. begin
  3.    ...
  4.    ...
  5. end;
  6.  

to this

Code: Pascal  [Select][+][-]
  1. procedure TCustomBCButton.AssignDefaultStyle;
  2. begin
  3.   {$I BCBUTTON.inc}
  4. end;
  5.  

and copy the attached file to the same location as bcbutton.pas. Rebuild the IDE.

Of course you can change the style in BCBUTTON.inc to suit your own needs.
« Last Edit: June 02, 2021, 06:36:56 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/
Re: [SOLVED] BGRAControls (BCButton)
« Reply #13 on: June 02, 2021, 05:29:59 am »
I live today not yesterday but thanks for the hint.  :-[

 

TinyPortal © 2005-2018