Ren'Py Text under the cursor

Black Ram oss

Black Ram
Game Developer
May 10, 2018
582
1,564
Hi, I'm creating a navigation screen.
I have inserted some buttons to make an action vertically, but inserting a text of what I am at the side or below is aesthetically ugly.
So I wanted to know how I can insert that text next to the cursor when I pass the cursor on the button.
The code of the buttons is more or less like this:
Python:
button xysize (110, 110):
    has vbox ysize 110 spacing 0
    frame xysize (110, 110) background None:
        imagebutton idle act.icon align (0.5, 0.0) focus_mask True:
            action [Hide('wait_navigation'), Jump(act.label)]
    # text act.name font 'DejaVuSans.ttf' size 18 drop_shadow [(2, 2)] xalign 0.5 text_align 0.5 line_leading 0 line_spacing -2
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
So I wanted to know how I can insert that text next to the cursor when I pass the cursor on the button.
You can use to know the position of the mouse.


Python:
button xysize (110, 110):
    has vbox ysize 110 spacing 0
    frame xysize (110, 110) background None:
        imagebutton idle act.icon align (0.5, 0.0) focus_mask True:
            action [Hide('wait_navigation'), Jump(act.label)]
    # text act.name font 'DejaVuSans.ttf' size 18 drop_shadow [(2, 2)] xalign 0.5 text_align 0.5 line_leading 0 line_spacing -2
What the hell is that button inside a button ? What were you even trying to achieve ?
What you want is the button proptery.

Code:
screen whatever():

    $ (x,y) = renpy.get_mouse_pos()

    for act in WHATEVER_IS_YOUR_LIST:
        imagebutton:
            idle act.icon
            align (0.5, 0.0 )
            focus_mask True
            action [Hide('wait_navigation'), Jump(act.label)]
            tooltip act.name

    $ text = GetTooltip()
    if text:
        text "[text]":
            xpos x
            ypos y
            font 'DejaVuSans.ttf' 
            size 18 
            drop_shadow [(2, 2)] 
            line_leading 0 
            line_spacing -2
Both xpos and ypos will in fact need to be adjusted for the text to not be shown exactly at the position of the mouse. But I let you find the values that match your desire.
 
  • Like
Reactions: Black Ram oss

Black Ram oss

Black Ram
Game Developer
May 10, 2018
582
1,564
Thank you very much.

What the hell is that button inside a button ? What were you even trying to achieve ?
i did it that way to make the space between the buttons to be 0 (i can't use it in imagebutton). do you know a better way to reduce or remove the gap between imagebutton?
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
do you know a better way to reduce or remove the gap between imagebutton?
The gap don't come from the button, but from the text ; more precisely from the font.
It's natural and expected to be here. But if really you want to get rid of it, use the style property.