[SOLVED]hover idle colors textbutton

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
User avatar
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

[SOLVED]hover idle colors textbutton

#1 Post by johandark »

In the main menu buttons I would like to have one color for "idle" and another for "hover".

(But only in main menu, so in the rest of the options keep the default settings).

This is the code that works now.

Code: Select all

    # The main menu buttons.
    frame:
        background None
        style_prefix "mm"
        xalign .15
        yalign .39

        has hbox

        textbutton _("Comenzar") background None action Start()
        textbutton _("Cargar partida") background None action ShowMenu("load")
        textbutton _("Opciones") background None action ShowMenu("preferences")
        textbutton _("Salir") background None action Quit(confirm=False)
        #textbutton _("Ayuda") action Help()

I´ve tried this code:

Code: Select all

        textbutton _("Comenzar") idle="#f00" hover="#fff" background None action Start()
But of course... it doesn´t work...

So... is there a right way to do it?

Thanks!
Last edited by johandark on Thu Jul 28, 2016 12:22 pm, edited 1 time in total.
Image

User avatar
morg
Regular
Posts: 95
Joined: Sun May 10, 2015 7:35 am
Projects: Cupid's Affair
Tumblr: n-morg
Contact:

Re: hover idle colors textbutton

#2 Post by morg »

add a style somewhere before start in your script

Code: Select all

style buttonz:
    idle "fe3eed"
    hover "d2d2d2"
    insensitive "888"
    background None
then assign it to your buttons like this

Code: Select all

textbutton _("Comenzar") style "buttonz" action Start()
Image

User avatar
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: hover idle colors textbutton

#3 Post by johandark »

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 21: style property idle is not known.
    idle "fe3eed"
        ^

Ren'Py Version: Ren'Py 6.99.10.1227
:(
Image

User avatar
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: hover idle colors textbutton

#4 Post by johandark »

I think this shouldn´t be so complicated...

I mean... in this forum xavimat showeed me a way to put a idle and hover on imagebutton:

Code: Select all

imagebutton idle "images/menu/i_back_idle.png" hover "images/menu/i_back_hover.png" action Rollback()
Why is so complicated do the same but with textbutton and just two different colors?!

like this:

Code: Select all

textbutton idle "#fff" hover "#000" action Rollback()
But this code doesn´t work...

WHY?! :(

any help please?

Thanks!
Image

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

Re: hover idle colors textbutton

#5 Post by xavimat »

In imagebuttons, "idle" and "hover" ARE the buttons themselves.
Instead, in textbuttons, the button is the TEXT, and what you want is to apply properties to that text when is hovered/unhovered. That's not easy because the textbuttons are a combination of button and text, and the color of the text of a textbutton is defined in the property "text_color" and not in "color" (as it is in in the "text" element).

So, you need to define a style and apply it with "text_style" or define directly text_color (for idle) and text_hover_color (for hover):

Code: Select all

style mytextbutton:
    color "#f00"
    hover_color "#ff0"

screen test():

    vbox:

        # Using the style:
        textbutton "Hello":
            text_style "mytextbutton"
            action NullAction()

        # Formatting directly without the style:
        textbutton "Hello":
            text_color "#f00"
            text_hover_color "#ff0"
            action NullAction()
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)

User avatar
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: hover idle colors textbutton

#6 Post by johandark »

Thank you xavimat!

Now it works!

And I even learned to create a Style! That´s nice!

Thanks! ;)
Image

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]