[SOLVED]We can renpy.set_focus, but how do we renpy.clear_focus? Similar to moving the mouse a little.

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
henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

[SOLVED]We can renpy.set_focus, but how do we renpy.clear_focus? Similar to moving the mouse a little.

#1 Post by henvu50 » Fri Oct 21, 2022 6:31 pm

edit: code to clear / lose focus is down below, thx to Ocelot

We can renpy.set_focus, but how do we renpy.clear_focus? Similar to moving the mouse a little. I just want to clear the focus from any button.

Is there anything like this, or a way to simulate it?

Code: Select all

renpy.clear_focus()
I'm resorting to creating a fake empty button that does nothing, and setting focus to it, to simulate losing focus, but this doesn't seem right. I shouldn't have to do this.

Code: Select all

    button:
        xsize 0
        ysize 0
        id 'simulate_losing_focus_by_setting_focus_on_me'
        keyboard_focus False
        hover_sound None
        activate_sound None
        action NullAction()
        
Last edited by henvu50 on Fri Oct 21, 2022 7:18 pm, edited 2 times in total.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: We can renpy.set_focus, but how do we renpy.clear_focus? Similar to moving the mouse a little.

#2 Post by Ocelot » Fri Oct 21, 2022 7:14 pm

You can try

Code: Select all

renpy.display.focus.set_focused(None, None, None)
renpy.restart_interaction()
Note: not tested, might now work properly.
< < insert Rick Cook quote here > >

henvu50
Veteran
Posts: 322
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: We can renpy.set_focus, but how do we renpy.clear_focus? Similar to moving the mouse a little.

#3 Post by henvu50 » Fri Oct 21, 2022 7:17 pm

Ocelot wrote:
Fri Oct 21, 2022 7:14 pm
You can try

Code: Select all

renpy.display.focus.set_focused(None, None, None)
renpy.restart_interaction()
Note: not tested, might now work properly.
It works. I just tested it. Works perfect so far, thank you.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]