[Solved] I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key.

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: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

[Solved] I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key.

#1 Post by henvu50 »

I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

NOTE: I did not disable keyboard focus of things like main_menu, preferences, save, load, and menus like that.
Last edited by henvu50 on Tue Jul 13, 2021 8:00 pm, edited 1 time in total.

tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#2 Post by tornsoul »

It would really help if you posted some code - A million things could be wrong...

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

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#3 Post by henvu50 »

tornsoul wrote: Mon Jul 12, 2021 3:53 pm It would really help if you posted some code - A million things could be wrong...
Hmm okay, how about this. In Ren'py create a brand new project.

Let's add this:

Code: Select all


# SCREENS.RPY
default quick_menu = False
# -------------------

screen test3():

    textbutton "Top":
        xalign 0.1
        yalign 0.1
        keyboard_focus False
        action NullAction()

    textbutton "Mid":
        xalign 0.2
        yalign 0.2
        keyboard_focus False
        action NullAction()

    textbutton "Bottom":
        xalign 0.8
        yalign 0.8
        keyboard_focus False
        action NullAction()
       
label start:
    show screen test3
    "this is a test" 
       
Now press the arrow keys and one of the textbutton's will still gain focus.
Last edited by henvu50 on Mon Jul 12, 2021 5:32 pm, edited 2 times in total.

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

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#4 Post by Ocelot »

Cannot reproduce. I can only switch focus between quickbar and say screen with keyboard.

Note that I had to fix tab character and inconsistent block size in your code before game could be launched.
< < insert Rick Cook quote here > >

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

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#5 Post by henvu50 »

Ocelot wrote: Mon Jul 12, 2021 4:05 pm Cannot reproduce. I can only switch focus between quickbar and say screen with keyboard.

Note that I had to fix tab character and inconsistent block size in your code before game could be launched.
I modified the code based on your suggestions and provided a more thorough example that should reproduce the problem.

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

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#6 Post by Ocelot »

Tested new code. First time, as expected, "Bottom" button could be focused (because of keyboard_focus True). Then I set keyboard_focus to False, and again, only quick menu and say screen could be focused

EDIT: Tried again with edited version, wasn't able to move focus from say screen. Updated to the latest release version to exclude possibility of bugs in latest version, still no hits.
< < insert Rick Cook quote here > >

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

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#7 Post by henvu50 »

Ocelot wrote: Mon Jul 12, 2021 5:34 pm Tested new code. First time, as expected, "Bottom" button could be focused (because of keyboard_focus True). Then I set keyboard_focus to False, and again, only quick menu and say screen could be focused

EDIT: Tried again with edited version, wasn't able to move focus from say screen. Updated to the latest release version to exclude possibility of bugs in latest version, still no hits.
First, I want to apologize. I don't mean to waste your time, but, I made a mistake again! I need to re-triple my efforts and focus. For some reason I forgot to include the menu code. I have no idea what could've been going through my head by not including that. I think I need to slow down, take two steps back.

With a clear head, this code should reproduce the problem, without a shadow of doubt.

Code: Select all

# SCREENS.RPY
default quick_menu = False
# -------------------

screen test3():

    textbutton "Top":
        xalign 0.1
        yalign 0.1
        keyboard_focus False
        action NullAction()

    textbutton "Mid":
        xalign 0.2
        yalign 0.2
        keyboard_focus False
        action NullAction()

    textbutton "Bottom":
        xalign 0.8
        yalign 0.8
        keyboard_focus False
        action NullAction()

label start:
    show screen test3
 
    # i can't believe I didn't include this. THIS IS THE WHOLE REASON i raised this issue. It's important this is here.
    menu:
        "A":
            "a"
        "B":
            "b"
    "this is a test"

So, despite buttons TOP, MID & BOTTOM being disabled from gaining keyboard_focus, the TOP button will still gain focus when you press the down arrow key. Then, when you press the down arrow key again, it will select the first menu choice A.

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

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#8 Post by Ocelot »

This is interesting. It appears that first displayable in the screen gets focus (I swapped Top and Mid blocks and Mid button started to gain focus). Even more: when I set Top button keyboard_focus to True, Mid STILL was getting focus first, before Top. I will get a closer look at it later, but it seems to be a bug.
< < insert Rick Cook quote here > >

User avatar
midgethetree
Regular
Posts: 39
Joined: Wed Dec 30, 2020 3:51 pm
Completed: Back When, The Mother of Pearls, various jam games
Projects: When Everyone's Watching, Deliberation
Github: midgethetree
itch: midge-the-tree
Discord: rainafc#3353
Contact:

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#9 Post by midgethetree »

I created a pull request to fix this just now, hopefully it'll be included in 7.4.7.

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

Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?

#10 Post by henvu50 »

midgethetree wrote: Tue Jul 13, 2021 6:47 pm I created a pull request to fix this just now, hopefully it'll be included in 7.4.7.
Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users