Image button stay on hover

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
MisterHarold
Regular
Posts: 51
Joined: Tue Jul 17, 2018 10:32 am
Location: Philippines
Contact:

Image button stay on hover

#1 Post by MisterHarold »

I have an imagebutton that changes while hovered over by mouse cursor. When I remove the mouse cursor it changes back to idle. How can I make the imagebutton stay on hover after hovering my cursor over it?

Code: Select all

imagebutton:
	idle "btn1.png"
	hover "btn2.png"

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Image button stay on hover

#2 Post by hell_oh_world »

It's how button states work. I don't know what you're trying to achieve here but maybe you can use a variable then set it using the hovered action then use the variable as the idle image.

Code: Select all

screen something():
  default idle_image = "btn1.png"
  imagebutton:
    action NullAction() # keeps the button hoverable
    hovered SetScreenVariable("idle_image", "btn2.png")
    idle idle_image
    hover "btn2.png"
this should probably keep the image in hover state forever unless you set the idle_image into something again.

Dr_arell
Regular
Posts: 70
Joined: Sun Feb 23, 2020 11:24 pm
Deviantart: DarellArt
Contact:

Re: Image button stay on hover

#3 Post by Dr_arell »

Hi, this is the way i usually do imagebuttons, what i see you are missing is the "unhovered" part, that can be either the variable, or your base image.

Code: Select all

unhovered SetVariable("hovered_door_variable", False)
and heres the full thing

Code: Select all

imagebutton:
       idle "/door.png" action Jump("label_to_fill") hovered SetVariable("hovered_door_variable", True) unhovered SetVariable("hovered_door_variable", False) focus_mask True

    	if hovered_door_variable:
       		add "/hovered_door.png"

default hovered_door_variable = False

Post Reply

Who is online

Users browsing this forum: No registered users