[Solved] Tooltips flash for a split second when button tapped on mobile.

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
henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

[Solved] Tooltips flash for a split second when button tapped on mobile.

#1 Post by henvu50 » Mon Aug 23, 2021 7:16 pm

If you press and hold a button on mobile, the tooltip shows correctly. It's quite helpful, but if you tap the button real fast, the tooltip will flash for a split second which is kind of annoying. Anyone know a solution where I can keep the tooltips on mobile, but not have it flash if the button tap only lasts a second or less?
Last edited by henvu50 on Tue Aug 24, 2021 12:25 pm, edited 1 time in total.

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

Re: Tooltips flash for a split second when button tapped on mobile.

#2 Post by Imperf3kt » Tue Aug 24, 2021 1:43 am

Tool tips activate on the hover event. If you only tap, you aren't hovering.

One solution I can think of might be to use the legacy tool tip listed in the documentation.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: Tooltips flash for a split second when button tapped on mobile.

#3 Post by henvu50 » Tue Aug 24, 2021 11:43 am

Imperf3kt wrote:
Tue Aug 24, 2021 1:43 am
Tool tips activate on the hover event. If you only tap, you aren't hovering.

One solution I can think of might be to use the legacy tool tip listed in the documentation.
When I simulate Android Phone via renpy, a click (simulating a tap) will trigger the tooltip to show for a split second. Are you saying on a real mobile phone it won't do that? I just tested on Android simulator and the tooltip still flashes, but let me try making a fresh & new project to make sure it's not my fault (user error).

Edit: I just made a new project. I used this example tooltip from the ren'py documentation. The tooltip will still flash for a split second in Android Studio and via Ren'py phone emulator.

Code: Select all

screen tooltip_example():
    vbox:
        textbutton "North":
            action Return("n")
            tooltip "To meet a polar bear."
        $ tooltip = GetTooltip()
        if tooltip:
            text "[tooltip]"


Edit: Okay time to try legacy tooltip.
Edit: Legacy Tooltip also flashes via this code in a new project.

Code: Select all

screen tooltip_test:
    default tt = Tooltip("")
    frame:
        xpos 500
        ypos 100
        xfill True
        has vbox
        textbutton "One.":
            action Return(1)
            hovered tt.Action("The loneliest number.")
        text tt.value size 60
I'm surprised no one else brought up this issue. That must mean that tooltip usage is not really a thing on mobile? When you tap and hold, you can clearly see the tooltip, so it does serve a helpful purpose if it didn't flash on tap.
Last edited by henvu50 on Tue Aug 24, 2021 12:21 pm, edited 3 times in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Tooltips flash for a split second when button tapped on mobile.

#4 Post by Alex » Tue Aug 24, 2021 12:09 pm

henvu50 wrote:
Mon Aug 23, 2021 7:16 pm
If you press and hold a button on mobile, the tooltip shows correctly. It's quite helpful, but if you tap the button real fast, the tooltip will flash for a split second which is kind of annoying. Anyone know a solution where I can keep the tooltips on mobile, but not have it flash if the button tap only lasts a second or less?
Kind of workaround is to add a tiny pause before showing the tooltip, like

Code: Select all

screen tooltip_example():
    default flag = False
    
    vbox:
        spacing 20
        pos (0.5, 0.2) anchor(0.0, 0.0)
        textbutton "North":
            action NullAction() #Return("n")
            tooltip "To meet a polar bear."

        textbutton "South":
            action NullAction() #Return("s")
            tooltip "All the way to the tropics."

        textbutton "East":
            action NullAction() #Return("e")
            tooltip "So we can embrace the dawn."

        textbutton "West":
            action NullAction() #Return("w")
            tooltip "Where to go to see the best sunsets."

        $ tooltip = GetTooltip()

        if tooltip:
            if not flag:
                timer 0.1 action SetScreenVariable("flag", True)
            else:
                text "[tooltip]"
        else:
            $ flag = False

# The game starts here.
label start:
    "..."
    call screen tooltip_example
    "?!"

henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: Tooltips flash for a split second when button tapped on mobile.

#5 Post by henvu50 » Tue Aug 24, 2021 12:22 pm

Alex wrote:
Tue Aug 24, 2021 12:09 pm
henvu50 wrote:
Mon Aug 23, 2021 7:16 pm
If you press and hold a button on mobile, the tooltip shows correctly. It's quite helpful, but if you tap the button real fast, the tooltip will flash for a split second which is kind of annoying. Anyone know a solution where I can keep the tooltips on mobile, but not have it flash if the button tap only lasts a second or less?
Kind of workaround is to add a tiny pause before showing the tooltip, like

Code: Select all

screen tooltip_example():
    default flag = False
    
    vbox:
        spacing 20
        pos (0.5, 0.2) anchor(0.0, 0.0)
        textbutton "North":
            action NullAction() #Return("n")
            tooltip "To meet a polar bear."

        textbutton "South":
            action NullAction() #Return("s")
            tooltip "All the way to the tropics."

        textbutton "East":
            action NullAction() #Return("e")
            tooltip "So we can embrace the dawn."

        textbutton "West":
            action NullAction() #Return("w")
            tooltip "Where to go to see the best sunsets."

        $ tooltip = GetTooltip()

        if tooltip:
            if not flag:
                timer 0.1 action SetScreenVariable("flag", True)
            else:
                text "[tooltip]"
        else:
            $ flag = False

# The game starts here.
label start:
    "..."
    call screen tooltip_example
    "?!"
Thanks for this. I'm going to try it right now.

EDIT: IT WORKED. Thank you so much. I set the time to 0.4, and I'll inform the user to press and hold any button they want more information on.

henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: [Solved] Tooltips flash for a split second when button tapped on mobile.

#6 Post by henvu50 » Tue Aug 24, 2021 1:19 pm

Just an FYI. I can't get Alex's code to work when using transclusion (USE statement).

For example, the tooltip & timer trick doesn't work here for some reason because the screen is being called via use:

Code: Select all

screen testA():
    text 'hi'
    use tooltip_example

screen tooltip_example():
    default flag = False
    
    vbox:
        spacing 20
        pos (0.5, 0.2) anchor(0.0, 0.0)
        textbutton "North":
            action NullAction() #Return("n")
            tooltip "To meet a polar bear."

        $ tooltip = GetTooltip()

        if tooltip:
            if not flag:
                timer 0.1 action SetScreenVariable("flag", True)
            else:
                text "[tooltip]"
        else:
            $ flag = False

# The game starts here.
label start:
    "..."
    show screen tooltip_example
    "?!"
It seems in order to get this code to work in the main & game menu's, I have to do this:

Code: Select all

screen main_menu():
# ..................
        default flag = False
        $ tooltip = GetTooltip()
        if tooltip:
            if not flag:
                timer 0.1 action SetScreenVariable("flag", True)
            else:
                text "[tooltip]"
        else:
            $ flag = False

screen game_menu():
# ..................
        default flag = False
        $ tooltip = GetTooltip()
        if tooltip:
            if not flag:
                timer 0.1 action SetScreenVariable("flag", True)
            else:
                text "[tooltip]"
        else:
            $ flag = False
A bit sloppy, but it's not a big deal. :)

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: [Solved] Tooltips flash for a split second when button tapped on mobile.

#7 Post by Alex » Tue Aug 24, 2021 1:59 pm

henvu50 wrote:
Tue Aug 24, 2021 1:19 pm
Just an FYI. I can't get Alex's code to work when using transclusion (USE statement)....
Not tested, but you could try to show a tooltip text at some transform, like

Code: Select all

transform tt_transform():
    alpha 0.0
    0.4
    alpha 1.0

Code: Select all

    if tooltip:
        text "[tooltip]" at tt_transform

henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: [Solved] Tooltips flash for a split second when button tapped on mobile.

#8 Post by henvu50 » Tue Aug 24, 2021 2:06 pm

Alex wrote:
Tue Aug 24, 2021 1:59 pm
henvu50 wrote:
Tue Aug 24, 2021 1:19 pm
Just an FYI. I can't get Alex's code to work when using transclusion (USE statement)....
Not tested, but you could try to show a tooltip text at some transform, like

Code: Select all

transform tt_transform():
    alpha 0.0
    0.4
    alpha 1.0

Code: Select all

    if tooltip:
        text "[tooltip]" at tt_transform
That worked very well. This issue is totally resolved. Thanks again.

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

Re: Tooltips flash for a split second when button tapped on mobile.

#9 Post by Imperf3kt » Tue Aug 24, 2021 5:57 pm

henvu50 wrote:
Tue Aug 24, 2021 11:43 am
Imperf3kt wrote:
Tue Aug 24, 2021 1:43 am
Tool tips activate on the hover event. If you only tap, you aren't hovering.

One solution I can think of might be to use the legacy tool tip listed in the documentation.
When I simulate Android Phone via renpy, a click (simulating a tap) will trigger the tooltip to show for a split second. Are you saying on a real mobile phone it won't do that? I just tested on Android simulator and the tooltip still flashes, but let me try making a fresh & new project to make sure it's not my fault (user error).

Edit: I just made a new project. I used this example tooltip from the ren'py documentation. The tooltip will still flash for a split second in Android Studio and via Ren'py phone emulator.

Code: Select all

screen tooltip_example():
    vbox:
        textbutton "North":
            action Return("n")
            tooltip "To meet a polar bear."
        $ tooltip = GetTooltip()
        if tooltip:
            text "[tooltip]"


Edit: Okay time to try legacy tooltip.
Edit: Legacy Tooltip also flashes via this code in a new project.

Code: Select all

screen tooltip_test:
    default tt = Tooltip("")
    frame:
        xpos 500
        ypos 100
        xfill True
        has vbox
        textbutton "One.":
            action Return(1)
            hovered tt.Action("The loneliest number.")
        text tt.value size 60
I'm surprised no one else brought up this issue. That must mean that tooltip usage is not really a thing on mobile? When you tap and hold, you can clearly see the tooltip, so it does serve a helpful purpose if it didn't flash on tap.
I misread your original post and thought you were asking why tooltips disappear after a tap.
Glad to see you've got it forged with some help.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

Post Reply

Who is online

Users browsing this forum: Google [Bot], span4ev