having tooltips appear when hovering over button

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
Nuxill
Veteran
Posts: 464
Joined: Sat Sep 25, 2010 4:50 pm
Projects: No Friend
Tumblr: nuxill
itch: nuxill
Contact:

having tooltips appear when hovering over button

#1 Post by Nuxill » Wed May 23, 2012 3:58 am

I'm trying to make an effect similar to one on the main menu of Ristorante Amore, where a tooltip appears when the player hovers over a button. I'm having a bit of trouble wrapping my head around the code though. Is it possible to have this kind of tooltip show up if you use an image button or text button, or is it something only imagemaps are capable of?

User avatar
SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: having tooltips appear when hovering over button

#2 Post by SundownKid » Wed May 23, 2012 4:15 am

I have something like this that involves creating separate screens with the text, then setting the button action to show said screen when hovered, and hide when unhovered.

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: having tooltips appear when hovering over button

#3 Post by Camille » Wed May 23, 2012 4:17 am

Buttons and hotspots both take hovered actions, so the code should still work. There's an actual tooltip function in Ren'Py, though, that might be easier to use than what I did.

User avatar
Nuxill
Veteran
Posts: 464
Joined: Sat Sep 25, 2010 4:50 pm
Projects: No Friend
Tumblr: nuxill
itch: nuxill
Contact:

Re: having tooltips appear when hovering over button

#4 Post by Nuxill » Wed May 23, 2012 4:43 am

Sundownkid wrote:I have something like this that involves creating separate screens with the text, then setting the button action to show said screen when hovered, and hide when unhovered.
I was thinking of doing something like this but a much more complicated version having to do with double the screens. I might try this
Camille wrote:Buttons and hotspots both take hovered actions, so the code should still work. There's an actual tooltip function in Ren'Py, though, that might be easier to use than what I did.
I'm not able to get the hovered action to work with a textbutton... I think I'm doing something wrong. I'm guessing

Code: Select all

    textbutton "dog":
        hovered Show("button1.png", transition=dissolve)
        unhovered Hide("button1.png", transition=dissolve)
is not the way to do it.

Also I didn't even know about the tooltip function! :shock: Thank you! Is there a way to position the text and buttons in different areas? I know it says that more complex behavior is possible but off the top of my head I can't think of how I would code it. doesn't help that it's 4:30 am over here! I need to go to bed...

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: having tooltips appear when hovering over button

#5 Post by Showsni » Wed May 23, 2012 4:57 am

You can use the usual commands to position the text and buttons anywhere you'd like. For instance, going off the example...

Code: Select all

screen tooltip_test:

    default tt = Tooltip("No button selected.")

    frame:
        xfill True
        xalign 0.0
        yalign 0.0

        has vbox

        textbutton "One.":
            action Return(1)
            hovered tt.Action("The loneliest number.")

        textbutton "Two.":
            action Return(2)
            hovered tt.Action("Is what it takes.")

        textbutton "Three.":
            action Return(3)
            hovered tt.Action("A crowd.")
    frame:
        vbox:
            xalign 0.7
            yalign 0.7
            text tt.value
That would let you move the frames containing the buttons and the text around seperately. You can of course set up your frames and windows and so on however you'd like.

The more complex actions it's referring to are when instead of using text tt.value you use some other command. The "tt.value" bit can be anything at all; the names of images, variables you want to update, etc. Then you can use any commands with it. Say you want a picture to flash up as a tooltip instead of some text, for instance.

User avatar
SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: having tooltips appear when hovering over button

#6 Post by SundownKid » Wed May 23, 2012 8:01 am

Is it possible to make these tooltips appear with transitions?

User avatar
Nuxill
Veteran
Posts: 464
Joined: Sat Sep 25, 2010 4:50 pm
Projects: No Friend
Tumblr: nuxill
itch: nuxill
Contact:

Re: having tooltips appear when hovering over button

#7 Post by Nuxill » Wed May 23, 2012 2:10 pm

Thank you very much Showsni! I'm also curious if it's possible to have the tooltips appear with transitions.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]