Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use TAction for an "icon only" TButton

I have a TAction that is used for both a menu item and a TButton. I want the menu item to show the label, and the TButton to show only the icon. However, when an Action is assigned, Vcl automatically sets the TButton's Caption attribute, and I cannot get rid of it.

Any ideas?

like image 304
Hendrik Avatar asked Dec 11 '12 08:12

Hendrik


1 Answers

On the menu item, set ImageIndex to -1. On the button, set the Caption to ''. You must do this at runtime.

This will break the association with the action for just those individual properties. The action will still be used for Hint, OnExecute, OnUpdate etc.

like image 73
David Heffernan Avatar answered Sep 25 '22 17:09

David Heffernan