[Solved] Getting hover_color from a style

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
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

[Solved] Getting hover_color from a style

#1 Post by _ticlock_ »

Hi, All,

How can I get the text hover_color from a style? For example, if I have a style mybutton and mybutton_text:

Code: Select all

style mybutton_text:
    color "#888888"
    hover_color "#0000ad"
There is no attribute hover_color in style.mybutton_text
I also tried combinations with hover: style.mybutton_hover_text.color, style.hover_mybutton_text.color, style.hover_mybutton_hover_text.color, but they have either the color "#888888" or "#ffffff".

Where the hover_color is actually stored or how can I get "hover" text style?
Last edited by _ticlock_ on Thu Feb 18, 2021 2:58 pm, edited 1 time in total.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Getting hover_color from a style

#2 Post by gas »

It SHOULD be style.mybutton.hover_text.color
As mybutton is the father of the style chain "mybutton_whatever".
It's hard to explain.
Not sure, but once it was that way.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Getting hover_color from a style

#3 Post by _ticlock_ »

gas wrote: Wed Feb 17, 2021 2:01 am It SHOULD be style.mybutton.hover_text.color
As mybutton is the father of the style chain "mybutton_whatever".
It's hard to explain.
Not sure, but once it was that way.
Hi, gas,

Unfortunately, there is no hover_text attribute in style.mybutton. I don't see anything related to font hover_color in style attributes:

Code: Select all

dir(style.mybutton) = 
['__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__pyx_vtable__', '__reduce__', '__reduce_cython__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__setstate_cython__', '__sizeof__', '__str__', '__subclasshook__', '_get', '_get_unoffset', '_visit_bar', '_visit_frame', '_visit_window', 'activate_sound', 'add_properties', 'adjust_spacing', 'aft_bar', 'aft_gutter', 'alt', 'altruby_style', 'antialias', 'background', 'bar_invert', 'bar_resizing', 'bar_vertical', 'black_color', 'bold', 'bottom_margin', 'bottom_padding', 'box_layout', 'box_reverse', 'box_wrap', 'box_wrap_spacing', 'caret', 'child', 'clear', 'clipping', 'color', 'copy', 'debug', 'delattr', 'drop_shadow', 'drop_shadow_color', 'first_indent', 'first_spacing', 'fit_first', 'focus_mask', 'focus_rect', 'font', 'fore_bar', 'fore_gutter', 'foreground', 'get_offset', 'get_placement', 'help', 'hinting', 'hover_sound', 'hyperlink_functions', 'inspect', 'italic', 'justify', 'kerning', 'key_events', 'keyboard_focus', 'language', 'layout', 'left_margin', 'left_padding', 'line_leading', 'line_overlap_split', 'line_spacing', 'min_width', 'mipmap', 'mouse', 'name', 'newline_indent', 'order_reverse', 'outline_scaling', 'outlines', 'parent', 'prefix', 'properties', 'rest_indent', 'right_margin', 'right_padding', 'ruby_style', 'set_parent', 'set_prefix', 'setattr', 'setdefault', 'size', 'size_group', 'slow_abortable', 'slow_cps', 'slow_cps_multiplier', 'spacing', 'strikethrough', 'subpixel', 'subtitle_width', 'take', 'text_align', 'text_y_fudge', 'thumb', 'thumb_offset', 'thumb_shadow', 'time_policy', 'top_margin', 'top_padding', 'underline', 'unscrollable', 'vertical', 'xanchor', 'xfill', 'xfit', 'xmaximum', 'xminimum', 'xoffset', 'xpos', 'xspacing', 'yanchor', 'yfill', 'yfit', 'ymaximum', 'yminimum', 'yoffset', 'ypos', 'yspacing']
That is why I thought it should be some "hover_" style, but as I said they have either the color "#888888" or "#ffffff"

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

Re: Getting hover_color from a style

#4 Post by Imperf3kt »

Is this a button? If so, without supplying an explicit style definition it will default to the button_text_hover_color style definition, which is interface_text_hover_color IIRC (haven't got anything to reference and I'm away from my PC)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Getting hover_color from a style

#5 Post by _ticlock_ »

Imperf3kt wrote: Wed Feb 17, 2021 4:19 pm Is this a button? If so, without supplying an explicit style definition it will default to the button_text_hover_color style definition, which is interface_text_hover_color IIRC (haven't got anything to reference and I'm away from my PC)
mybutton is button style and mybutton_text is text style. Hover_color and styles are defined like this:

Code: Select all

style mybutton is text_button
style mybutton_text is text_button_text

style cropbutton:
    ...

style cropbutton_text:
    color "#888888"
    hover_color "#0000ad"
I tried style.mybutton_text_hover_color as you mentioned but it says such style does not exist. I also tried style.mybutton_text_hover_text but it shows color "#ffffff".

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Getting hover_color from a style

#6 Post by hell_oh_world »

Hi, All,

How can I get the text hover_color from a style? For example, if I have a style mybutton and mybutton_text:

Code: Select all

style mybutton_text:
    color "#888888"
    hover_color "#0000ad"
There is no attribute hover_color in style.mybutton_text
I also tried combinations with hover: style.mybutton_hover_text.color, style.hover_mybutton_text.color, style.hover_mybutton_hover_text.color, but they have either the color "#888888" or "#ffffff".

Where the hover_color is actually stored or how can I get "hover" text style?
try... style.mybutton_text.properties[0]["hover_color"]

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Getting hover_color from a style

#7 Post by _ticlock_ »

hell_oh_world wrote: Thu Feb 18, 2021 5:02 am try... style.mybutton_text.properties[0]["hover_color"]
hell_oh_world,

Right. It worked.

Thank you for the help!!!

Post Reply

Who is online

Users browsing this forum: No registered users