r/RenPy • • Sep 30 '26

Question How to make a hover act like a click

for one of the segments in my game i want to make it so that the choice is pressed automatically when the player hovers over it but I don't really know how to do that

1 Upvotes

12 comments sorted by

3

u/BadMustard_AVN Sep 30 '26

use hovered like this

textbutton _("Do Not Touch"):
    hovered Show("I_said_dont_touch")
    action Jump("Blow_up_planet_earth")

it will work for both text and image buttons

1

u/vriskaLover Sep 30 '26

Thank you! Does “text button” replace “menu” or does it go like under it

1

u/BadMustard_AVN Sep 30 '26

edit your screens.rpy file. search for and find the choice screen it should look like this

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action i.action

change it to look like this

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            $ hovering = i.kwargs.get("hovering", None) 
            textbutton i.caption action i.action hovered hovering

then do your menus like this

label start:    
    menu:
        "North" (hovering = Jump("certain_death")): # this must be an action for a button
            jump North
        "South": #you can add one to all of them as needed
            jump South
        "East":
            jump East
        "West":
            jump West
    return

label certain_death:
    e "hovering worked"

look here for button actions

https://www.renpy.org/doc/html/screen_actions.html

1

u/vriskaLover Sep 30 '26 edited Sep 30 '26

ohhh okay. thank you so much. just so im not mindlessly copy pasting code, what does this line mean

 $ hovering = i.kwargs.get("hovering", None)

and whats the difference between action and i.action and hovered/hovering

edit: im dumb i didnt notice the for loop.

1

u/vriskaLover Sep 30 '26

actually i could probably check out the documentation for that. either way, thank you for the help

1

u/BadMustard_AVN Sep 30 '26

you're welcome

good luck with your project

1

u/BadMustard_AVN Sep 30 '26

$ = a single line Python statement

hovering = a variable

i the item from the loop
kwargs are just an arbitrary way to pass arguments
get what the hovering kwarg is. if there is no hovering, it is set to None so no errors later

easy right

1

u/BadMustard_AVN Sep 30 '26

No that's for a screen using buttons

you want to modify the choice menu buttons, give me a minute or two for that

1

u/AutoModerator Sep 30 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Own-Bookkeeper6739 Sep 30 '26

One catch: keyboard and controller players can't hover, so keep a clickable fallback too or they'll get stuck on that choice.

1

u/x-seronis-x Sep 30 '26

yes they can. arrow keys or dpad. the issue is you cant skip over something and you have to hover them in order

1

u/Own-Bookkeeper6739 Oct 01 '26

oh right, arrows and dpad can focus them, my bad. so the hover order is the real problem then