Add a generic GuiButton class

As a Roblox developer, it is really strange to have to use ImageButtons or TextButtons for textureless and textless buttons in UI development. I find myself using simply colored buttons for things and having to use a specialized button for a generic purpose feels really weird. It’s always felt weird because that’s not what they’re made for.

If a generic GuiButton class that was just a button with no text or image were added, I would feel more comfortable using buttons that weren’t text or image based.

A great example of when you would have to use a blank ImageButton or TextButton is if you were designing a UI that had multiple pieces of text or images inside of an area that was meant to be one clickable space. I’ve had this happen specifically when making lists of clickable elements that have text and an image in them. I end up having to put Labels seperate from a blank button, which is weird because I’m essentially misusing an existing class to replicate basic functionality. It works, but we could do with a generic alternative.

33 Likes

I almost never use the TextButton class’s text property simply because there’s no option to handle where exactly your text will be. Sure, there’s a text truncation property, but I’d have full control over where the text is in a button.

Overall though, I agree with the post - I think another thing that could work is to replace the Image & TextButton classes, and instead combine them both into a single object with perimeters to activate the text or image properties, the text having a better text position property. .

5 Likes

I think creating a new class is the wrong approach.

Why should we have to choose between text, an image background, or specifically neither? Both TextButtons and ImageButtons should be rolled into one class. What if I want a button with a generic button background image and dynamic text on top? I otherwise need to use an ImageButton and manually place a Label myself. If I want a featureless button element, I should be able to do that simply by not providing any visual properties.

6 Likes

There’s no padding option for text objects, such as actual text placement.

2 Likes

At first it sounded like you wanted another button class to be added, just with less properties. But combining the ImageButton and TextButton properties is a really good idea (if that’s what you were implying).

1 Like

I’ve thought about it more, and as much as I like the idea of combining image & text labels into one class, you’re still going to have the problem of not being able to place text correctly, and thus, I feel like a blank class should replace the TextButton class, with TextLabels / TextBoxes replacing the text functionality.

However, if Roblox is able to add proper text positioning to objects with TextProperties, then I think a class that combines both TextButtons and ImageButtons could work out fantastically.

I would really appreciate this. Although the same effect can be achieved by clearing the specific properties of a TextButton or ImageButton, a broader context variant makes sense without redundant text/image rendering.

Example: A button without an image texture that has a dynamic text element (e.g. text that changes position when you hover over the button).

Another example: A catch-all button that encompasses a multitude of elements.

Bumping this.

I use quite a large number of buttons in my game, and the vast majority of them are ImageButtons that I don’t use the Image property for. This is because most of the time, slapping on an image for the button isn’t enough, as there may be other decorations placed on the button (such as moving objects), or none at all.

1 Like