Is it possible to add python code to image 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
User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Is it possible to add python code to image on hover?

#1 Post by Luxliev »

I want to achieve something similiar to what you can achieve with buttons but instead of button I want to achieve it on image (not imagebutton) I'd like to change hovered variable on hover:

Code: Select all

screen test():
    hbox:
        pos (0.0, 0.5)
        textbutton "Test":
            hovered SetVariable("hover", 1)
            unhovered SetVariable("hover", 0)
            action NullAction()
        textbutton "[hover]"
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
firecat
Miko-Class Veteran
Posts: 540
Joined: Sat Oct 25, 2014 6:20 pm
Completed: The Unknowns Saga series
Projects: The Unknown Saga series
Tumblr: bigattck
Deviantart: bigattck
Skype: bigattck firecat
Soundcloud: bigattck-firecat
Contact:

Re: Is it possible to add python code to image on hover?

#2 Post by firecat »

yes is possible but screen language might not be the best option since you will have to recreate another hbox and another, which could be messy coding.
Image


Image


special thanks to nantoka.main.jp and iichan_lolbot

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Is it possible to add python code to image on hover?

#3 Post by philat »

Like dude, what is your personal crusade against screen language? Luxliev asked how to use hover state for images and your response is don't use screen language? How is that helpful?

Luxliev, AFAIK, vanilla images don't have hover states. I would imagine you'd have to use imagebuttons, some combination of mouseareas/hotspots/button-like screen elements and images (at which point, seems you might as well use imagebuttons), or CDDs (which I freely admit I know very little about). I could be wrong, of course, but why do you need hover for images rather than buttons?
Last edited by philat on Wed Nov 18, 2015 8:33 pm, edited 1 time in total.

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Is it possible to add python code to image on hover?

#4 Post by nyaatrap »

Code: Select all

fixed fit_first True:
    add image
    button hovered []

Code: Select all

button hovered []:
        hover_background image
There are several ways.

Post Reply

Who is online

Users browsing this forum: Dark79, Google [Bot], Majestic-12 [Bot]