Hover 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.
Message
Author
User avatar
Ragnos
Regular
Posts: 60
Joined: Thu Oct 27, 2016 3:22 pm
Contact:

Hover text

#1 Post by Ragnos »

Not sure if this is possible in Renpy, but is it possible to have a line of text appear by your mouse when you hover over an option? Like when you hover your mouse over the exit button in the top right of this webpage it says "close"
I want to give information to the player before they choose an option.

Could anyone help?
Image

User avatar
NialGrenville
Regular
Posts: 184
Joined: Tue Aug 30, 2016 6:30 pm
Projects: PaS: The Awakening; The Heart Woods; The Witch and the Fairy
Organization: Gabe Works, Inc.
Contact:

Re: Hover text

#2 Post by NialGrenville »

ToolTips!

Here's the documentation on it: documents

Here's a fourm post on it: fourm post

Unfortunately I haven't used tooltips yet. So I can't give you a straightforward answer in code as of now. Hopefully those links will help you!
*Me*, *You, ***Calamazoo: *Singularity-A.I.*: *Proceed to processing
PaS: The Awakening, current status: 42%
The HeartWoods, current status: 0%
The Wonderful Mell! My PFI creator Honest Critique

User avatar
Ragnos
Regular
Posts: 60
Joined: Thu Oct 27, 2016 3:22 pm
Contact:

Re: Hover text

#3 Post by Ragnos »

NialGrenville wrote:ToolTips!

Here's the documentation on it: documents

Here's a fourm post on it: fourm post

Unfortunately I haven't used tooltips yet. So I can't give you a straightforward answer in code as of now. Hopefully those links will help you!
Thanks, I'll give it a look see.
Image

User avatar
Ragnos
Regular
Posts: 60
Joined: Thu Oct 27, 2016 3:22 pm
Contact:

Re: Hover text

#4 Post by Ragnos »

I'm having some trouble creating city choices for the player. I have images of all the cities show up in a 3 2 grid format, but I cannot get the tooltips to work or continue with dialogue after the choice. I haven't tried yet to adding the unlocking of cities yet.

Base Code

Code: Select all

# City Selection & Stats
###################################################################

 screen CitySelect:
    
   grid 3 2:
      imagebutton idle "Cities/City001.jpg":
        "This is City1"
      imagebutton idle "Cities/City002.jpg"
      imagebutton idle "Cities/City003.jpg"
      imagebutton idle "Cities/City004.jpg"
      imagebutton idle "Cities/City005.jpg"
      imagebutton idle "Cities/City006.jpg"


Though I'm sure I'm just being a noob about this...
Image

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Hover text

#5 Post by Divona »

You haven't use Tooltip() in the code at all. The code would be something like this.

Code: Select all

# City Selection & Stats
###################################################################

 screen CitySelect:
 
    #  define variable as Tooltip with empty string
    default tt = Tooltip("")

    grid 3 2:
        imagebutton idle "Cities/City001.jpg" hovered tt.Action("This is City 1")
        imagebutton idle "Cities/City002.jpg" hovered tt.Action("This is City 2")
        imagebutton idle "Cities/City003.jpg" hovered tt.Action("This is City 3")
        imagebutton idle "Cities/City004.jpg" hovered tt.Action("This is City 4")
        imagebutton idle "Cities/City005.jpg" hovered tt.Action("This is City 5")
        imagebutton idle "Cities/City006.jpg" hovered tt.Action("This is City 6")

    frame:
        # set this frame to the position of the mouse
        pos renpy.get_mouse_pos()

        # display text with value set in tt.Action() above.
        text tt.value
Completed:
Image

User avatar
Ragnos
Regular
Posts: 60
Joined: Thu Oct 27, 2016 3:22 pm
Contact:

Re: Hover text

#6 Post by Ragnos »

I did, but after I couldn't get it to work I went back to the base code I started with.
Sorry for any confusion
Image

User avatar
Ragnos
Regular
Posts: 60
Joined: Thu Oct 27, 2016 3:22 pm
Contact:

Re: Hover text

#7 Post by Ragnos »

Well so far I can get text pop up if nothing is selected, but nothing when I hover over the images. I've tried a few different things but they didn't work.

At this point I'm thinking of just having a description get displayed after choosing which city then ask the player player for confirmation .
Attachments
Current.png
Image

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Hover text

#8 Post by Divona »

Want to post the code up, so we can see what went wrong?
Completed:
Image

User avatar
Ragnos
Regular
Posts: 60
Joined: Thu Oct 27, 2016 3:22 pm
Contact:

Re: Hover text

#9 Post by Ragnos »

It's the same as the code you provided. The one you provided didn't work except the 'No selection'. I tried a few other things but they didn't work either.

Mainly what I'm trying to do is have all but two cities locked until the player gets a certain score during previous gameplay.
Image

User avatar
Ragnos
Regular
Posts: 60
Joined: Thu Oct 27, 2016 3:22 pm
Contact:

Re: Hover text

#10 Post by Ragnos »

I'm going to rewrite the whole thing and do away with the tooltip idea since it's become more trouble than what it's worth.
Image

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: Hover text

#11 Post by papiersam »

Did you give the imagebuttons actions? If you don't complete it, it tends to bug up. Try:

Code: Select all

# City Selection & Stats
###################################################################

screen CitySelect:
 
    #  define variable as Tooltip with empty string
    default tt = Tooltip("")

    grid 3 2:
        imagebutton idle "Cities/City001.jpg" hovered tt.Action("This is City 1") action NullAction()
        imagebutton idle "Cities/City002.jpg" hovered tt.Action("This is City 2") action NullAction()
        imagebutton idle "Cities/City003.jpg" hovered tt.Action("This is City 3") action NullAction()
        imagebutton idle "Cities/City004.jpg" hovered tt.Action("This is City 4") action NullAction()
        imagebutton idle "Cities/City005.jpg" hovered tt.Action("This is City 5") action NullAction()
        imagebutton idle "Cities/City006.jpg" hovered tt.Action("This is City 6") action NullAction()

    frame:
        # set this frame to the position of the mouse
        pos renpy.get_mouse_pos()

        # display text with value set in tt.Action() above.
        text tt.value

label start:
    call screen CitySelect
If that doesn't work, we could always try the traditional tooltip.

User avatar
Ragnos
Regular
Posts: 60
Joined: Thu Oct 27, 2016 3:22 pm
Contact:

Re: Hover text

#12 Post by Ragnos »

r_sami wrote:Did you give the imagebuttons actions? If you don't complete it, it tends to bug up. Try:
If that doesn't work, we could always try the traditional tooltip.
Alright, I haven't gotten around to working on it yet, but I'll definitely give this a try. Thanks.

It gave me an error on NullAction() BUT I put a regular empty string statement and it... FINALLY WORKED!
Thank you so much! This thread can now be closed.
Image

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Hover text

#13 Post by xavimat »

The explanation could be this:
If a button/imagebutton/textbutton has no action, then it is "insensitive", and the "hovered" action is not triggered.
For this reason exists the NullAction(). To have buttons sensitive to hover/unhover when they do nothing on click (or for testing purposes).
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

IM6
Newbie
Posts: 1
Joined: Fri Jan 25, 2019 12:21 am
Contact:

Re: Hover text

#14 Post by IM6 »

Hi all, sorry to do (quite) a bit of a necro here, but as this is the first search result I got when googling for the same issue, I thought I'd help with a solution I devised that I think works quite simply and effectively. I haven't seen it anywhere else myself, so apologies if it's common knowledge elsewhere.

My goal was to create a textbutton that, when hovered, would show some text. Basically, I create a variable outside of the screen itself, then have the hovered and unhovered actions change the variable value. Then, the desired text is shown or not shown based on the variable using a showif statement.

For the example given above, you ought to also be able to use this variable to store the text you wish to display, and depending on which button is hovered, store the descriptive text in that variable, then do a showif that variable meets one of those criteria, using the variable itself as the text to be displayed.

Anyway, here's my code - it should be fairly easy to adapt:

Code: Select all

#variable that allows hover text to show or not
default objHov = "Unhovered"

screen statoverlay():

    textbutton "Current Objective" ypos 5 xpos 145:
        action NullAction() #Required to allow hover actions
        hovered SetVariable("objHov", "Hovered")
        unhovered SetVariable("objHov", "Unhovered")
        #Setting text format for text shown in button
        text_font "badaboom.ttf"
        text_color "#b995b9"
        text_outlines [ (1, "#000000", 0, 0 ) ]
    showif objHov == "Hovered":
        text objective ypos 100 xpos 15 size 30 font "badaboom.ttf"
        #where objective is a variable modified throughout the game in script.rpy

User avatar
G0RG3h
Newbie
Posts: 17
Joined: Tue Nov 02, 2021 8:59 am
Projects: Circle Head
itch: g0rg3h
Contact:

Re: Hover text

#15 Post by G0RG3h »

necro but i had a hard time editing the code above and finally got it working for anyone who saw it and wanted it to be framed/or an imagebutton/ one screen and no clicks like me! ^^ :D

just change the images and stuff to your stuff. (ie the frame and stfsays and hover stuff! that's for my character as a like...real time reaction image!)

Code: Select all


default stfhov = "Unhovered"

screen buttonstf():

        zorder 2 #to be over textbox, disappears right after tho as it is still a tooltip
        
        imagebutton:
            idle "images/buttonstfidle.png"
            hover "images/buttonstfhover.png"
            xalign 0.1
            yalign 0.9
            action NullAction() #Required to allow hover actions
            hovered SetVariable("stfhov", "Hovered")
            unhovered SetVariable("stfhov", "Unhovered")
            #Setting text format for text shown in button
            #text_font "badaboom.ttf"
        showif stfhov == "Hovered":
            frame:
                ypadding 100
                xpadding 100
                yalign 0.75
                xalign 0.05
                background Frame("images/minitextbox.png", xalign=0.5, yalign=1.0)
                vbox:
                    text stfsays xpos 0 ypos -12 size 30
 #
edit:

I added a dissolve to mine, and I wanted to update.

Code: Select all

            
            #........upper code
            #text_font "badaboom.ttf"
        showif stfhov == "Hovered":
            frame at alpha_dissolve2:
                ypadding 100
                xpadding 100
                yalign 0.75
                xalign 0.05
                background Frame("images/minitextbox.png", xalign=0.5, yalign=1.0)
                vbox:
                    text stfsays xpos 0 ypos -12 size 30

transform alpha_dissolve2:
    on show:
        alpha 0.0
        linear 1.0 alpha 1.0
    on hide:
        alpha 1.0
        linear 1.0 alpha 0.0
<<<<damn you len>>>>>

Post Reply

Who is online

Users browsing this forum: No registered users