Skip to main content
Known Participant
November 15, 2018
Question

Generate a standard button with an icon inside?

  • November 15, 2018
  • 2 replies
  • 1621 views

I've searched the forums and I know this has been asked around quite a bit but I can never find a completely clear answer. I'm looking to create a button with an icon and standard text next to it, like the image attached. I don't want to create an icon button but rather have a small icon within the button itself.

Any thoughts?

Thanks.

Ben

This topic has been closed for replies.

2 replies

Alan_AEDScripts
Inspiring
December 19, 2018

The most obvious way to do this is use an icon button, and bake in the text with the image. You can embed the binary string for the png in your file if you only want a jsx etc.

Another option would be using 'stack' layout and put an icon button (smaller width) over a normal button (for text) - both with same callback. Clunky and limited but works.    

zlovatt
Inspiring
November 15, 2018

Why the reluctance to use an icon button?


You could explore this method for drawing SVGs-- maybe create a group, draw the SVG on the left, add text on the write, and add an `onClick` for the whole group.

Known Participant
November 15, 2018

sorry re-read your comment again and I realize what you are saying now. "Draw SVG on the left add text on the right." Now if only that code accepted bezier curves instead of just points.

UQg
Legend
December 9, 2018

Iconbuttons have a "title" (String) and "titleLayout" (Object) properties.

But that's the kind of ScriptUI features that does seem to be maintained in a working state, so it's risky to use.

I just made a try in CC 2018.
The title is printed correctly next to the image, but the titleLayout is completely ignored.

btn.image = ScriptUI.newImage(myFile);

btn.title = "test";

btn.titleLayout = {alignment: ['right', 'center']};

The title is put on the left of the image, whatever the alignment value i tried.

No luck here, since you want the title on the right.

Xavier.