[SOLVED] Is there a way to have hovered tooltip on a text?

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
Ace94
Regular
Posts: 113
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

[SOLVED] Is there a way to have hovered tooltip on a text?

#1 Post by Ace94 »

Hey. I know tooltip can be used on imagebutton and textbutton, but what about just text?

I tried to be smart and use empty imagebutton on the spot where the text was placed in the screen, but whenever I hover over it moves the text for some reason.
Last edited by Ace94 on Fri Jul 10, 2020 6:49 am, edited 1 time in total.

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

Re: Is there a way to have hovered tooltip on a text?

#2 Post by philat »


Ace94
Regular
Posts: 113
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Re: Is there a way to have hovered tooltip on a text?

#3 Post by Ace94 »

That doesn't really help me. That's for dialogue and I need it in text. I need it for something like this:

Code: Select all

screen timer_screen():

    add "gui/image.png"
    modal True

    #Total played time
    $ minutes, seconds = divmod(int(persistent.runtime), 60)
    $ hours, minutes = divmod(minutes, 60)
    vbox:
        xalign 0.588 yalign 0.338
        text "Total time played: [hours]h:[minutes]m:[seconds]s " style "time_played" #<--- tooltip with style here
So, when the player hovers over "total time played + the hours,minutes and seconds" I can show a tooltip saying that the timer doesn't count time spent in menus. I also have a few imagebutton tooltips in the same screen with styles and I want the text and tooltip to be with the same style.

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

Re: Is there a way to have hovered tooltip on a text?

#4 Post by philat »

Hyperlinks work in text in screens.

Ace94
Regular
Posts: 113
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Re: Is there a way to have hovered tooltip on a text?

#5 Post by Ace94 »

philat wrote: Fri Jul 10, 2020 4:52 am Hyperlinks work in text in screens.
So I can't just have the tooltip appear when hover?

User avatar
MaydohMaydoh
Regular
Posts: 165
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: Is there a way to have hovered tooltip on a text?

#6 Post by MaydohMaydoh »

Use a textbutton in place of the text

Ace94
Regular
Posts: 113
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Re: Is there a way to have hovered tooltip on a text?

#7 Post by Ace94 »

MaydohMaydoh wrote: Fri Jul 10, 2020 5:07 am Use a textbutton in place of the text
Okay, so I got this to work, but there's an issue. When I hover over the text it moves upwards and creates a duplicate underneath for some reason. Here's a pic showing what I mean:

Unhovered:
Image

And when I hover with the mouse:
Image

Here's the full code:

Code: Select all

        textbutton "Total time played: [hours]h:[minutes]m:[seconds]s" action NullAction() text_style "inventory_played_time_button_text" anchor (0.5,0.5) tooltip "1"
        $ tooltip = GetTooltip()

        if tooltip == "1":
            image "gui/inv_timer_tooltip.png" xpos 1000 ypos 500 anchor (0.5,0.5)
Any ideas how to fix that?

Ace94
Regular
Posts: 113
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Re: Is there a way to have hovered tooltip on a text?

#8 Post by Ace94 »

I found the problem! I was using vbox on the textbutton which made it appear twice for some reason. Removing that fixed the problem! Thanks, guys!

Post Reply

Who is online

Users browsing this forum: No registered users