How to make a button fit the size of its icon?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ciavarie

I have icons of the size 35x35 pixels, which I load with the following code:

var texture = load("res://UserInterface/Item_icons/"+icon_name)

whenever the icon gets loaded to empty button of the same size, this button extends around the icon, so one can see the ugly grey margin of the button. Expand icon is turned off.
I tried to set the margin, but that does only change the appearance of the empty button without icon. When the icon is loaded, it does not matter what I did the margin set to in the editor.
Why does the button extend around its icon and how can I make them fit together, so one can not see the button behind the icon anymore?
I would gladly appreciate any hints.

:bust_in_silhouette: Reply From: mdubaisi

what about using theTextureButton node

This would lead to redoing the UI. I will do so, if there really is no way to accomplish it with the icons.

Ciavarie | 2020-09-02 11:54