how to make Button respond to its image child?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
PasswordIsntHunter2
Newbie
Posts: 19
Joined: Sun Jan 07, 2018 6:23 pm
Contact:

how to make Button respond to its image child?

#1 Post by PasswordIsntHunter2 »

I have a Button (the screen language Button which takes multiple children), with a Text and an Image (using "add") inside it. If I hover over the text, the Button's "hovered" action is run, and if I click on the text, the "action" is run. But if I hover over the image or click on the image, it's completely unresponsive. How do I get the button to respond to either of the elements inside it? Isn't that what it's for in the first place?

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: how to make Button respond to its image child?

#2 Post by Remix »

Code: Select all

    button:
        focus_mask Image("a.png") # non transparent pixels = sensitive
Note: You could also use TextButton and set:

Code: Select all

    textbutton "The Text":
        focus_mask Image("a.png") # non transparent pixels = sensitive
        background ... an image or (often better to auto scale) Frame
        hover_background ... ditto for hover
Frameworks & Scriptlets:

PasswordIsntHunter2
Newbie
Posts: 19
Joined: Sun Jan 07, 2018 6:23 pm
Contact:

Re: how to make Button respond to its image child?

#3 Post by PasswordIsntHunter2 »

Using focus_mask as my image means the only sensitive part of the button is the image. Making a custom focus_mask image with a box where the text would be is not possible, since the text can be of arbitrary length. Setting the focus_mask to True or None also does not seem to work (the image portion is still not sensitive), despite what https://www.renpy.org/doc/html/style_properties.html says.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: how to make Button respond to its image child?

#4 Post by Remix »

It works fine if using textbuttons and scalable Frames with alpha images for focus_mask and all backgrounds. Never tried it through using button: so cannot really help further.
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Doeny, Kocker, Majestic-12 [Bot]