More customisation for Buttons made using ContextActionService

ContextActionService is a useful service that lets us bind user input to actions, using CAS we can also create buttons for those actions.

The issue lies with the limited and lackluster customisation for the buttons made using CAS.
We are only able to set an image for the inside as well as a title. We are not able to change the button image itself, or create our own press effect.

These restraints means that we either have to code our own buttons or live with the fact that the buttons made using CAS will most certainly clash with our games art direction.

There should be more functions related to the buttons made using CAS. My suggestions are below:

ContextActionService:SetButtonImage("ExampleButton", "rbxassetid://0000") — Changes the image of the button.
ContextActionService:SetIconImage("ExampleButton", "rbxassetid://0000") -- Replaces :SetImage(). If Developers want to use the image for the Button that Roblox provides and just set an icon then they can.
ContextActionService:SetPressFunction("ExampleButton", PressEffect) -- PressEffect has one parameter, which is the Button itself.

What’s the difference between SetButtonImage() and SetIcon()?
And correct me if I’m wrong, but isn’t the “SetImage” method below partially what you’re suggesting?

Current Methods

Couldn’t you also just use GetButton to get the button object and then change parts of it?

SetButtonImage would set the image of the button to the image you supplied. Currently, SetImage sets the icon inside the button to the image you supplied.

I experimented, and you can change the button image with code - but as soon as you press the button it returns to what it originally was.

I posted this late at night, so apologies that I suggested a function that already exists - but SetIconImage tells you clearly what the function does unlike SetImage.

1 Like

I apologize, because I was reading this at like, 2 or 3 am last night. I see now that SetButtonImage would be like the background image, and SetIconImage would set the smaller icon used inside of the background.

And that’s true, better naming of functions would help a lot in most cases as well as for this as it would be a little more descriptive of the full use.

Roblox currently has PressedImage for buttons, and I’m assuming you could use that to change the image when it’s pressed, unless you’re saying it changes it back after.