[SOLVED] Problem with Textbutton Hover

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
redeller
Newbie
Posts: 4
Joined: Fri Aug 12, 2022 5:14 pm
Contact:

[SOLVED] Problem with Textbutton Hover

#1 Post by redeller » Thu Aug 18, 2022 8:25 pm

Hi I'm having trouble with textbutton styling. So far, this is my code:

Code: Select all

style fight_button:
    color "#3f1414" 
    size 100
    pos(300,100) 
    font "../fonts/arcade_n.ttf"
    hover_color "#926464" 

style flight_button:
    color "#3f1414" 
    size 100
    pos(1050,100) 
    font "../fonts/arcade_n.ttf"
    hover_color "#926464"
for both of the textbuttons (they are basically the same except for position). Here is how I call them:

Code: Select all

textbutton "FIGHT" text_style "fight_button" action [SetVariable("fight", True)] at my_shake, fade_in2
textbutton "FLIGHT" text_style "flight_button" action [SetVariable("flight", True)] at my_shake, fade_in3
        
They both show up fine, but the problem occurs when I hover over the button, it doesn't select the proper area. At the pos specified, the textbutton is not selected. But when I hover my mouse at the top left of the screen, the "FLIGHT" button is selected. I tried playing around with the pos, action, and text but it remains the same. The button is not recognized in the correct area.

What am I doing wrong?

Thanks in advance!
Last edited by redeller on Mon Aug 22, 2022 10:40 pm, edited 1 time in total.

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

Re: Problem with Textbutton Hover

#2 Post by Imperf3kt » Fri Aug 19, 2022 12:19 am

Are you using the textbuttons as part of a screen, or directly in your script?
For example, this is incorrect, don't use screen language like this:

Code: Select all

label start:
    "Textbuttons are screen language, this is not a screen."
    "This example is incorrect."
    textbutton "myButton" action NullAction()
    return
The correct way to use a textbutton:

Code: Select all

## Place this somewhere in screens.rpy, or outside any label.
screen fight():
    vbox:
        textbutton "myButton" action NullAction()
        
## The rest goes in script.rpy
label start:
    "This is one of many correct ways to show a textbutton."
    show screen fight
    "the button should now show"
    return
There are many more ways top show the button and control how it behaves, all depends what exactly you want to achieve, for example, you may want to call the screen instead or might want to call the screen with keyword arguments so the position of the button can be changed dynamically etc.
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: Bing [Bot], Google [Bot]