Making Tooltip Appear After Few Seconds

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
Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Making Tooltip Appear After Few Seconds

#1 Post by Nero »

Does anyone knows how to make tooltip appear only after you hold mouse cursor at the textbutton for 2 seconds (example)? Is there some easy code line I'm missing or its complex thing to code?

Code: Select all

default tt = Tooltip("")

screen test():
    text tt.value xsize 1200 yalign 0.500 xalign 0.500
    textbutton "Tooltip Button":
        hovered tt.Action("Some stuff...")
        action NullAction()

label start:
    show screen test
    "..."
    "..."
    "..."
    "..."
    "..."

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Making Tooltip Appear After Few Seconds

#2 Post by Imperf3kt »

You can certainly add that feature and the coding required is probably around amateur level.

You'll likely want to use the new tool tip function, the kind you're using isn't supported any more (though there are some uses for it still)
https://www.renpy.org/doc/html/screen_a ... p#tooltips

I'm unable to provide an example at the moment, but the basic idea is you have a screen that contains your tool tip and using the on show function, fade it in after two seconds.
Upon hovering a button, you show that screen and renpy takes care of the rest. I hovering will hide the screen.

Will try to post an example when able.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Re: Making Tooltip Appear After Few Seconds

#3 Post by Nero »

Oh I corrected the mistake on tooltip new method is easier to use. Yeah example of this in action would be nice thanks.

By the way I was looking at your other posts about tooltips that follow mouse cursor but it seems its outdated also so if you did it for new renpy maybe you can post link of updated version since I cant find it?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Making Tooltip Appear After Few Seconds

#4 Post by Imperf3kt »

Nero wrote: Thu Mar 19, 2020 8:30 am Oh I corrected the mistake on tooltip new method is easier to use. Yeah example of this in action would be nice thanks.

By the way I was looking at your other posts about tooltips that follow mouse cursor but it seems its outdated also so if you did it for new renpy maybe you can post link of updated version since I cant find it?
Sorry, didn't have time last night to create an example, will try again tonight.

But that's great that you checked out my other posts, it helps a lot when people search :D

As to being outdated, no it shouldn't be, that was put together in the latest build of Ren'Py and still works fine for me.
Is it not working for you? I can help you implement it if you'd like to try it. The principles are very similar to what I suggested earlier.

Let me know what error or issue it gives you and I'll help you take care of it when I find some time (I'm getting busier and busier the last few months, so forgive me if I can't reply in a timely fashion)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Re: Making Tooltip Appear After Few Seconds

#5 Post by Nero »

Late reply is better than no reply at all :D. It is okay I work on other things while I wait for your response.

Without you and other nice people on this forum I would be stuck with my problems forever I'm grateful for your existence.

Well about mouse tooltip when I run it it is okay but when I hover over buttons nothing happens I can only see "No button selected." at the top left corner. However IF i press RIGHT mouse button while holding my mouse cursor at the button and then press right mouse button again the tooltip will appear on location I held my mouse but it will be frozen at that spot. If I repeat same thing happens tooltip stays at the place I was holding my mouse cursor last time.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Making Tooltip Appear After Few Seconds

#6 Post by Imperf3kt »

Sorry about the very late reply here, my PC was in need of repair and I have been far busier than normal these past few weeks (months, really). I've dusted my laptop off and moved files around so I can test things there. I'm using Ren'Py 7.3.2.320, which is a bit outdated, but everything works nicely for me. I've updated to 7.3.5.606 just to be sure, and everything still works nicely here.

If I've re-read the thread right, you want the tooltip to appear only after the button has been hovered for two seconds? And you want to implement the mouse-following tooltip?

I've tried for hours and I can't seem to make it behave how I expect. I'm afraid I can't really help with this, do you really need the tooltip to appear seconds after hovering? Is it working as expected otherwise?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

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

Re: Making Tooltip Appear After Few Seconds

#7 Post by hell_oh_world »

This is how i do my tooltip... I have to use a timer to keep track of mouse position, otherwise, the position of the tooltip would be delayed... This one has a delay that you can set through ATL

Code: Select all

default last_hint = "" # a placeholder for the recent tooltip

init python:
    def getTooltip():
        if GetTooltip():
            store.last_hint = GetTooltip()
        return store.last_hint

screen sample:
    default position = (0, 0)
    default show_tooltip = False
    
    timer 0.02 repeat True action SetScreenVariable("position", renpy.get_mouse_pos())

    vbox:
        textbutton "Hover to Show Tooltip":
            align (0.5, 0.0)
            action NullAction()
            hovered SetScreenVariable("show_tooltip", True)
            unhovered SetScreenVariable("show_tooltip", False)

            tooltip "FIRST BUTTON!!!"

        textbutton "Hover to Show Tooltip":
            align (0.5, 0.0)
            action NullAction()
            hovered SetScreenVariable("show_tooltip", True)
            unhovered SetScreenVariable("show_tooltip", False)

            tooltip "SECOND BUTTON!!!"

    showif show_tooltip and GetTooltip():
        use tooltip(getTooltip(), position, 1.5) # pass the text you want to display, the position of the tooltip and the delay before showing.

screen tooltip(hint, position, delay=1.5):

    frame:
        anchor (0.0, 0.0)
        pos position
        at tooltip_fade(delay)

        background Solid("#353535")
        text (hint if hint else ""):
            color "#fff"

transform tooltip_fade(delay):
    on start:
        alpha 0.0
        offset (15, 15)
    on show:
        pause delay
        easein 0.5 alpha 1.0
    on hide:
        easeout 0.5 alpha 0.0

label start:
    show screen sample
    "Hover over the buttons..."

Post Reply

Who is online

Users browsing this forum: Google [Bot]