Why ? :/I need force a ren'py button's hover state to true.
Yes, to tell the player that the cursor is actually hover this button. Forcing the hovered state mean that, not only the state itself lost its meaning, but also the player will then be deprived of a way to know when the button is hovered.Example, when you mouse over a button, its hover state is set to true.
if
structure that change the style applied to the button. Something like:screen whatever():
textbutton "this":
if actionIsSure:
style "noPossibleFailure"
elif actionCanFail:
style "possibleFailure"
else:
style "areYouCrazy"
style noPossibleFailure is button
style noPossibleFailure_text:
color "#00FF00"
[...]
What is the interest exactly ?I'm trying to make Ren'py 100% playable with the keyboard in a VERY effective way,
The only problem of the key system is that its too strict ; a vertical move should go to the next line, not to the next line in the actual column. The rest is just due to the fact that the quick menu is made of buttons.but Ren'py's current key system is bugged to hell.
keysym
and alternate_keysym
button's properties.No, it would solve nothing and your system would not works.If I could set a button's hover state to true programmatically, it will solve all my problems, and I could create a system that works 100% perfectly.
And you feel this for what reason exactly ?I'm close, I can feel it.
renpy.get_widget
is wrong ; it expect an id as second parameter.b.focus = True
.Text
object, more precisely a renpy.text.text.Text
object. Its focus
method expect to find a hyperlink.Button
object you're looking for, you'll still be far to the solution. You found the focus
method in the behavior.py script, but apparently misunderstood its code. So I'll give you a commented version : def focus(self, default=False):
# Call the father method ; see below.
super(Button, self).focus(default)
# Return value set at None by default.
rv = None
# If the button is focused, but not because the screen is
# displayed for the first time and it's the button declared
# as "default button" for this screen
if not default:
# Assign to /rv/ the value of the /hovered/ property
# for this button.
rv = run(self.hovered)
# Apply the "hover" ATL event related to this button.
self.set_transform_event(self.role + "hover")
# If the button have a child, also apply the "hover"
# ATL event to it.
if self.child is not None:
self.child.set_transform_event(self.role + "hover")
# Return the value of /rv/
return rv
focus
method is renpy.display.core.Displayable
, and it's code is: def focus(self, default=False):
"""
Called to indicate that this widget has the focus.
"""
# Change the style of the button for it to now
# use the "hover_" variation of it.
self.set_style_prefix(self.role + "hover_", True)
# If the button is focused, but not because the screen is
# displayed for the first time and it's the button declared
# as "default button" for this screen
if not default:
# Play the sound defined by the /hover_sound/
# property, if defined.
renpy.exports.play(self.style.hover_sound)
I abandoned the approach and will heed your wisdomWhat is the interest exactly ?
The only problem of the key system is that its too strict ; a vertical move should go to the next line, not to the next line in the actual column. The rest is just due to the fact that the quick menu is made of buttons.
But if really you want to make it works fully with the keyboard, just use thekeysym
andalternate_keysym
button's properties.
No, it would solve nothing and your system would not works.
And you feel this for what reason exactly ?
Here's the four reasons why you are still far from the solution:
1)
Your use ofrenpy.get_widget
is wrong ; it expect an id as second parameter.
So far, whatever you'll try, you'll continue to get the same NoneType object has no attribute named "[whatever]" exception. Both the documentation and error being explicit enough, you shouldn't even have tried something more than your initialb.focus = True
.
2)
Assuming that you solve the previous problem, the widget you'll then get would be aText
object, more precisely arenpy.text.text.Text
object. Itsfocus
method expect to find a hyperlink.
3)
Once you'll solve the previous problem, and finally get theButton
object you're looking for, you'll still be far to the solution. You found thefocus
method in the behavior.py script, but apparently misunderstood its code. So I'll give you a commented version :
If you trace back the inheritance, the only father with aPython:def focus(self, default=False): # Call the father method ; see below. super(Button, self).focus(default) # Return value set at None by default. rv = None # If the button is focused, but not because the screen is # displayed for the first time and it's the button declared # as "default button" for this screen if not default: # Assign to /rv/ the value of the /hovered/ property # for this button. rv = run(self.hovered) # Apply the "hover" ATL event related to this button. self.set_transform_event(self.role + "hover") # If the button have a child, also apply the "hover" # ATL event to it. if self.child is not None: self.child.set_transform_event(self.role + "hover") # Return the value of /rv/ return rv
focus
method isrenpy.display.core.Displayable
, and it's code is:
How do you expect this to help you in any possible way to solve your problem ?Python:def focus(self, default=False): """ Called to indicate that this widget has the focus. """ # Change the style of the button for it to now # use the "hover_" variation of it. self.set_style_prefix(self.role + "hover_", True) # If the button is focused, but not because the screen is # displayed for the first time and it's the button declared # as "default button" for this screen if not default: # Play the sound defined by the /hover_sound/ # property, if defined. renpy.exports.play(self.style.hover_sound)
4)
What you want isn't to tell a button that it is hovered, but to tell Ren'py, that "this button" is the one actually hovered. Therefore, not only what you are searching isn't at all where you are looking, but also the whole process you are following is wrong from the start.
I'll give you another piece of wisdom, that I learned from a mentor, who surely himself learned it from a mentor:I abandoned the approach and will heed your wisdom
keysym
and alternate_keysym
. They rely on a different approach that browsing the UI with the arrow keys, but still offer a possibility to link the keyboard to the UI buttons.