Recent

Author Topic: RxLib - TToolPanel: Add new item to ToolPanel  (Read 1398 times)

Renato Ricci

  • New Member
  • *
  • Posts: 22
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
RxLib - TToolPanel: Add new item to ToolPanel
« on: July 04, 2025, 02:58:03 pm »
Hello, Is there anyway to add a item in TToolPanel in runtime? I have some buttons/items added at designtime working perfect!. But inside FormCreate I want to add 1 more item, (if user is admin for exemple)...
However, this new item appears upabove the other items rather than align to the right side.. It looks like a bug on the toolbar.. see attached image:

FormCreat code:
Quote
var
  v_toolbaritem: TToolbarItem;
begin
if vg_admin then
  v_toolbaritem := ToolPanel1.Items.Add(my_action_admin); 
end;

Am I doing it correct?

Thanks
Renato
« Last Edit: July 04, 2025, 05:06:21 pm by Renato Ricci »

wp

  • Hero Member
  • *****
  • Posts: 13350
Re: RxLib - TToolPanel: Possible Bug - Add new item to ToolPanel
« Reply #1 on: July 04, 2025, 03:15:21 pm »
I don't see a solution either. Maybe create the additional button at designtime and set its Visible property to false initially?

BTW, what is it that you need from TToolPanel that the standard TToolBar cannot give you?

Renato Ricci

  • New Member
  • *
  • Posts: 22
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: RxLib - TToolPanel: Possible Bug - Add new item to ToolPanel
« Reply #2 on: July 04, 2025, 03:56:27 pm »
Hi WP..

ToolBar would be great if I could increment its button size to 48x48 and also let the users choose what button they want to keep visible inside ToolPanel like ToolPanel does. This resource/screen is native in RxLib.. See image:

Thats why I would prefer keep ToolPanel instead ToolBar..

Creating another button would work wither, however its appearance would be different from others existing ones..

May be I will wait for this bug fix so I can use the native way to add item inside ToolPanel.

Thanks
Renato

wp

  • Hero Member
  • *****
  • Posts: 13350
Re: RxLib - TToolPanel: Possible Bug - Add new item to ToolPanel
« Reply #3 on: July 04, 2025, 04:01:39 pm »
Ah, there's a Customize dialog... From here I could deduct the solution:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   v_toolbaritem: TToolbarItem;
  4. begin
  5.   v_toolbaritem := ToolPanel1.Items.Add(Action3);
  6.   ToolPanel1.VisibleItems.Add(v_toolbaritem);
  7.   ToolPanel1.Realign;
  8. end;  

Renato Ricci

  • New Member
  • *
  • Posts: 22
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: RxLib - TToolPanel: Possible Bug - Add new item to ToolPanel
« Reply #4 on: July 04, 2025, 04:19:21 pm »
I already had tried ToolPanel1.Realign.. it does not work :(

Did it work on yours???

Thanks

wp

  • Hero Member
  • *****
  • Posts: 13350
Re: RxLib - TToolPanel: Possible Bug - Add new item to ToolPanel
« Reply #5 on: July 04, 2025, 04:22:31 pm »
Yes, otherwise I would not have posted the code. Did you see that you must add the new toolbaritem to the VisibleItems before?

Renato Ricci

  • New Member
  • *
  • Posts: 22
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: RxLib - TToolPanel: Possible Bug - Add new item to ToolPanel
« Reply #6 on: July 04, 2025, 04:40:41 pm »
Ohh. Sorry! I missread the VisibleItems.add line.

Let me try it and I will tell you the result...

Renato Ricci

  • New Member
  • *
  • Posts: 22
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: RxLib - TToolPanel: Possible Bug - Add new item to ToolPanel
« Reply #7 on: July 04, 2025, 05:06:07 pm »
@wp, Thanks so much for helping!

VisibleItems.add worked perfectly!

I appreciate your help!

Have a good weekend!

Bye
Renato


wp

  • Hero Member
  • *****
  • Posts: 13350
Re: RxLib - TToolPanel: Possible Bug - Add new item to ToolPanel
« Reply #8 on: July 04, 2025, 05:20:09 pm »
ToolBar would be great if I could increment its button size to 48x48 [...]
This is already possible: Set the Toolbar's ButtonHeight to something like 52 and the ButtonWidth to 64, and AutoSize to true.

[...] and also let the users choose what button they want to keep visible inside ToolPanel like ToolPanel does.
Do you think that a "Customize" dialog allowing to move tool buttons between a "visible" and a "hidden" list would be a welcome addition? And also to rearrange the order of the buttons?

Renato Ricci

  • New Member
  • *
  • Posts: 22
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: RxLib - TToolPanel: Add new item to ToolPanel
« Reply #9 on: July 04, 2025, 06:47:01 pm »
@wp, good to know it is possible to set ButtonHeight on ToolBar.. Thanks for let me know..

About Customize Dialog, with RxLib you can call ToolPanel1.Customize(0); so the popup window shows and you can choose the visible and order of buttons. See Image attached.

Would be great it to have it in ToolBar.. However since ToolPanel already offers it, I dont know it is worth to create a new feature on ToolBar component.. May be who already utilize native ToolBar can give the most apropriate opinion. ;)

Thanks wp!
Renato
« Last Edit: July 04, 2025, 07:35:34 pm by Renato Ricci »

 

TinyPortal © 2005-2018