Page 1 of 1
[Solved] I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key.
Posted: Mon Jul 12, 2021 12:55 pm
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.
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Mon Jul 12, 2021 3:53 pm
by tornsoul
It would really help if you posted some code - A million things could be wrong...
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Mon Jul 12, 2021 3:56 pm
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.
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Mon Jul 12, 2021 4:05 pm
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.
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Mon Jul 12, 2021 5:29 pm
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.
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Mon Jul 12, 2021 5:34 pm
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.
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Tue Jul 13, 2021 5:57 pm
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.
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Tue Jul 13, 2021 6:34 pm
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.
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Tue Jul 13, 2021 6:47 pm
by midgethetree
I created a
pull request to fix this just now, hopefully it'll be included in 7.4.7.
Re: I set all displayables to keyboard_focus = False, yet one of them still gains focus via arrow key. Anyone know why?
Posted: Tue Jul 13, 2021 7:59 pm
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!