[SOLVED] Why does 'background' in the condition disable 'hover_background'?

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
span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

[SOLVED] Why does 'background' in the condition disable 'hover_background'?

#1 Post by span4ev » Thu Oct 27, 2022 3:03 am

I have a layout with non-standard sized buttons that I create in the loop, so I have to set my own background for a particular button.

Code: Select all

vbox:
    for i in range(len(btns)):
        hbox:
            for k in range(len(btns[i]))
                textbutton btns[i][k]:
                    background If(i == 0 or k == 3, btn_opers_bg, btn_nums_bg)
And because of this all the buttons don't have hover_background, which are written in the styles

Code: Select all

style main_button:
    background btn_nums_bg
    hover_background btn_nums_hover_bg
    xysize              btn_size
Why the conditions for background dominate - I understand. But I don't understand why it disables the visibility of the already existing hover_background in the styles, because it's a different property. Also, it's about the background, but not about other parameters, which are also set in the styles, for example - height.

I understand that I can explicitly specify hover_background here

Code: Select all

for k in range(len(btns[i]))
    textbutton btns[i][k]:
        background If(i == 0 or k == 3, btn_opers_bg, btn_nums_bg)
        hover_background 'some_color'
But I want to understand the principle of this problem and, if possible, put all the styles in style blocks instead of specifying them in the loop body
Last edited by span4ev on Thu Oct 27, 2022 9:41 pm, edited 1 time in total.

User avatar
_ticlock_
Veteran
Posts: 391
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Why does 'background' in the condition disable 'hover_background'?

#2 Post by _ticlock_ » Thu Oct 27, 2022 12:08 pm

span4ev wrote:
Thu Oct 27, 2022 3:03 am
I understand that I can explicitly specify hover_background.

But I want to understand the principle of this problem and, if possible, put all the styles in style blocks instead of specifying them in the loop body
Setting the background property sets the idle_background and hover_background properties.
If you are using style for the button and want to override only idle_background:

Code: Select all

                textbutton btns[i][k]:
                    idle_background If(i == 0 or k == 3, btn_opers_bg, btn_nums_bg)

span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

Re: Why does 'background' in the condition disable 'hover_background'?

#3 Post by span4ev » Thu Oct 27, 2022 9:40 pm

_ticlock_ wrote:
Thu Oct 27, 2022 12:08 pm
span4ev wrote:
Thu Oct 27, 2022 3:03 am
I understand that I can explicitly specify hover_background.

But I want to understand the principle of this problem and, if possible, put all the styles in style blocks instead of specifying them in the loop body
Setting the background property sets the idle_background and hover_background properties.
If you are using style for the button and want to override only idle_background:

Code: Select all

                textbutton btns[i][k]:
                    idle_background If(i == 0 or k == 3, btn_opers_bg, btn_nums_bg)
Thank you so much!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]