give the keyboard back when a modal closes
Hiding the layer takes the focus off whatever stood on it and leaves the window with no focus widget at all, so the world view answered no keys afterwards: Escape opened the menu once, closed it, and then did nothing. Each modal now notes what held the keyboard when it opened and gives it back on the way out -- the world view for the first of a stack, the modal beneath for one above it, which was dead the same way. The window's own focus guard now also catches the focus going nowhere, rather than only landing on the wrong widget. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <QColor>
|
||||
#include <QPoint>
|
||||
#include <QPointer>
|
||||
#include <QRect>
|
||||
#include <QWidget>
|
||||
|
||||
@@ -65,6 +66,12 @@ private:
|
||||
{
|
||||
ModalDialog* content;
|
||||
QScrollArea* host;
|
||||
// What held the keyboard when this modal opened, given back when it closes.
|
||||
// Hiding the layer, or closing a modal a second one was opened from, leaves the
|
||||
// window with no focus widget at all, and a window with none answers no keys --
|
||||
// Escape included, which is what opens the menu (REQ-UI-GAME-MENU). A QPointer
|
||||
// because a modal may outlive what it took the focus from.
|
||||
QPointer<QWidget> focusBefore;
|
||||
};
|
||||
|
||||
// Sizes content to what it asks for, capped at the layer, and centers it on
|
||||
|
||||
Reference in New Issue
Block a user