Re: [hatari-devel] no more "return" key in fileselector object ? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
On 3.9.2024 18.07, Nicolas Pomarède wrote:
I noticed that when you use the fileselector (to load a TOS image or a
floppy image) pressing "return" doesn't do anything anymore.
Also other means of exiting file selector using keyboard (e.g. ESC) do
not work any more.
Before it had the same behavioiur as clicking on the "OK" button, which
was handy to quickly confirm a file after selecting it in the list ; now
you need to explicitely click on OK.
If you slowly press the key several times, it may still close the
dialog. I.e. behavior is now partly random.
It's that expected ? (sorry, can't tell at the moment when this changed
but there were not many changes to SDL UI recently, so it should be easy
to find)
Cause of the regression is Thomas' fix to keyboard handling corner-case:
https://git.tuxfamily.org/hatari/hatari.git/commit/src/gui-sdl/sdlgui.c?id=bd8a07aef850a0ff2abfd588fef5a1e07f464100
Attached patch reverts the new behavior for cases like file selector.
I think being able to use keyboard to exit file selector is much more
relevant than the fixed corner case (user invoking file selector
shortcut while already keeping some dialog exit key down).
- Eero
From 39252a1f15af5dd73c8cb8f4aec05a11da294052 Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Wed, 4 Sep 2024 01:56:14 +0300
Subject: [PATCH] Fix: regression for exiting fileselector using keyboard
Fixes: bd8a07aef850
---
src/gui-sdl/sdlgui.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/gui-sdl/sdlgui.c b/src/gui-sdl/sdlgui.c
index c17e05de..107bcf10 100644
--- a/src/gui-sdl/sdlgui.c
+++ b/src/gui-sdl/sdlgui.c
@@ -1182,12 +1182,18 @@ int SDLGui_DoDialogExt(SGOBJ *dlg, bool (*isEventOut)(SDL_EventType), SDL_Event
/* If one of the keys that could exit the dialog is already held
* before we start, then ignore the first keyup event since the
* key press does not belong to the dialog, but rather to whatever
- * happened before the dialog */
+ * happened before the dialog.
+ *
+ * Cannot be used when asked to return already on key down
+ * (e.g. with file selector).
+ */
keystates = SDL_GetKeyboardState(NULL);
- ignore_first_keyup = keystates[SDL_GetScancodeFromKey(SDLK_RETURN)] ||
+ ignore_first_keyup = !(isEventOut && isEventOut(SDL_KEYDOWN)) && (
+ keystates[SDL_GetScancodeFromKey(SDLK_RETURN)] ||
keystates[SDL_GetScancodeFromKey(SDLK_KP_ENTER)] ||
keystates[SDL_GetScancodeFromKey(SDLK_SPACE)] ||
- keystates[SDL_GetScancodeFromKey(SDLK_ESCAPE)];
+ keystates[SDL_GetScancodeFromKey(SDLK_ESCAPE)]
+ );
/* Is the left mouse button still pressed? Yes -> Handle TOUCHEXIT objects here */
SDL_PumpEvents();
--
2.39.2