Button hovered+unhovered bug/quirk/feature?

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
drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Button hovered+unhovered bug/quirk/feature?

#1 Post by drKlauz » Sat Sep 03, 2016 9:53 am

Hi, if anyone can offer simple fix for this i would really appreciate it.

Expectations: hover mouse over textbutton, you see "Button#n hovered", move mouse from textbutton, text change to "Nothing hovered".

Reality: hover mouse over textbutton, you see "Button#n hovered", then right click or hit esc, you goes to save screen, then click return there, you back to game, no buttons actually hovered, but text is still "Button#n hovered".

Unhovered action didn't fired. How to fix it? Or how to get expected behavior in different way?

I have some ugly workaround in mind with DynamicDisplayable polling renpy.display.focus.get_focused every 0.1 second or so, but it's really ugly and cpu-not friendly.

Code: Select all

image DynaThing=DynamicDisplayable(GetDynaThing)

init python:
  Thing=None

  def GetDynaThing(st,at):
    if Thing is None:
      return Text("!!! Nothing hovered !!!"),None
    else:
      return Text("!!! Button#"+str(Thing)+" hovered !!!"),None

screen Test:
  vbox:
    add "DynaThing"
    textbutton "Button#1":
      action NullAction()
      hovered SetVariable("Thing",1)
      unhovered SetVariable("Thing",None)
    textbutton "Button#2":
      action NullAction()
      hovered SetVariable("Thing",2)
      unhovered SetVariable("Thing",None)
    textbutton "Button#3":
      action NullAction()
      hovered SetVariable("Thing",3)
      unhovered SetVariable("Thing",None)

label start:
    show screen Test

    "You've created a new Ren'Py game."

    return

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Button hovered+unhovered bug/quirk/feature?

#2 Post by drKlauz » Sat Sep 03, 2016 10:12 am

Ok, i cheated.

Code: Select all

...
screen navigation():
    python:
      store.Thing=None
    # The background of the game menu.
...
Same thing probably should go to after_load label.

But i still honestly like to know is it normal behavior? Is there any other options?
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Button hovered+unhovered bug/quirk/feature?

#3 Post by drKlauz » Sat Sep 03, 2016 11:11 am

I cheated badly, remember that "no side effects code in screens"? That was kinda it. Screen prediction can get called really unexpectedly. Don't do thing i done in previous post.

This solution works bit better.

Code: Select all

image DynaThing=DynamicDisplayable(GetDynaThing)

define Thing=None

init python:
  def GetDynaThing(st,at):
    if Thing is None:
      return Text("!!! Nothing hovered !!!"),None
    else:
      return Text("!!! Button#"+str(Thing)+" hovered !!!"),None

  def ResetThing():
    store.Thing=None
  config.start_interact_callbacks.append(ResetThing)

screen Test:
  vbox:
    add "DynaThing"
    textbutton "Button#1":
      action NullAction()
      hovered SetVariable("Thing",1)
      unhovered SetVariable("Thing",None)
    textbutton "Button#2":
      action NullAction()
      hovered SetVariable("Thing",2)
      unhovered SetVariable("Thing",None)
    textbutton "Button#3":
      action NullAction()
      hovered SetVariable("Thing",3)
      unhovered SetVariable("Thing",None)

label start:
    show screen Test
    "You've created a new Ren'Py game."
    return
Hope it will help someone in future.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Button hovered+unhovered bug/quirk/feature?

#4 Post by namastaii » Sun Sep 04, 2016 10:09 am

Eh... I've never used 'None' before. I don't know if that is correct syntax or not but you might have better luck creating three different variables and setting them to true when it's hovered and false when unhovered. Thing1, Thing2, Thing3. But that's just me. I have elements like this in my game and they work fine.

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Button hovered+unhovered bug/quirk/feature?

#5 Post by drKlauz » Sun Sep 04, 2016 1:29 pm

None is normal value, like 23 or "asdf" or False.
Problem there in unhovered action not called once screen is hidden.
Also i don't know exactly how much buttons shown on screen, they created dynamically, this example is just minimal code what showed problem.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Button hovered+unhovered bug/quirk/feature?

#6 Post by xela » Mon Sep 05, 2016 5:49 pm

Yeap, it got nothing to do with None, I (and many others) wrote about these issues in the past.

When the default Ren'Py ShowMenu system that goes out of context is used, a number of issues arise. Solution proposed by Klauz is perfectly fine to solve this specific problem, I dropped using Ren'Py default system in favor of Modal screen setup very, very long time ago and wrote about advantages and disadvantages of both in several posts since then.

If ShowMenu() menu system is dropped, such an issue will not occur, although there could be a number of different problems so it becomes a matter of preferences.

imo: Modal screens setup is superior to the ShowMenu() so I've made my choice looong time ago when it was proposed by in 2014:
Asceai wrote:...It might be a good idea to abandon your ShowMenu()/Return() design and move to a Show()/modal True/Hide() design instead.

...I nuked it from my game entirely, hence my automatic suggestion to anyone with ShowMenu() difficulties is to get rid of ShowMenu()
Like what we're doing? Support us at:
Image

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Button hovered+unhovered bug/quirk/feature?

#7 Post by drKlauz » Tue Sep 06, 2016 1:48 am

Thanks, good to know i'm not only one with such problems, will look into modal screens.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
Renpie
Newbie
Posts: 14
Joined: Sat Jul 11, 2015 9:49 am
Contact:

Re: Button hovered+unhovered bug/quirk/feature?

#8 Post by Renpie » Tue Dec 22, 2020 8:00 am

I got this same problem and I'll simply disable the ESC key and right click functions when in the screen with code below.

Code: Select all

$ _game_menu_screen = None
I'll enable it after making choice.

Code: Select all

$ _game_menu_screen = 'save'
And I'll make a button somewhere in the corner that enters the save menu.

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Button hovered+unhovered bug/quirk/feature?

#9 Post by drKlauz » Tue Dec 22, 2020 5:07 pm

Old one :D
Got other ways of doing that thing i believe. Plus RenPy evolved a bit last 4 years.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

Post Reply

Who is online

Users browsing this forum: No registered users