Page 1 of 1

Combine imagebutton and text into one button?

Posted: Tue Nov 21, 2017 3:38 pm
by Errilhl
Is that possible?

I can think of ways to work around this, of course, like creating a button-background which is wider than the actual image (character image), and just placing the text above it, but that seems like a hackish workaround.

What I would like is for a stats-screen to work with having both an image of the character, and the name of the character, and preferably both be clickable (like it was all one button), and open the same content (stats).

Is this easily possible using an already existing imagebutton?

Re: Combine imagebutton and text into one button?

Posted: Tue Nov 21, 2017 4:58 pm
by RicharDann
I asked a similar question some time ago:

viewtopic.php?f=8&t=45941#p466450

I went with Remix's suggestion in the end because I needed the automatic image change on hover imagebutton provides, but if your character's image doesn't need to change and you only need button functionality then using Button is also a valid option.

Re: Combine imagebutton and text into one button?

Posted: Tue Nov 21, 2017 7:30 pm
by Remix
The 'just stack all the stuff on top of each other in a fixed' approach, as suggested, would work fine, though you might also want to look at using text button.

From a quick 'rather untested' sleuth around the code, TextButton seems to sit on a scalable frame and actually changes the frame image on hover and unhover. It shouldn't be too tricky to track down the 'choice_button' styles in gui.rpy, make some new ones and add some hover/idle images to the game/gui folder (like the choice_ ones in there that are used for menu: blocks)
Then it would just be a case of:
... textbutton "{space=10}{image='icon.png'}{space=4}The Name{space=10}" style_prefix="whatever" action ... etc