put the caret in the name prompt's line edit
The layer asked the modal's focusWidget() what to focus, but hosting a modal reparents it into a scroll area and a reparent clears the focus its constructor set, so the answer was always nothing and the dialog itself took the keyboard. Modals now name their initial focus widget outright, which survives the hosting. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
@@ -66,17 +66,15 @@ int ModalLayer::execute(ModalDialog& content, const QRect& anchorRect)
|
||||
content.show();
|
||||
updateVisibility();
|
||||
|
||||
// The modal's own focus widget where it has one -- a name dialog puts the caret in
|
||||
// The widget the modal names where it names one -- a name dialog puts the caret in
|
||||
// its line edit -- and the modal itself otherwise, so keys reach it and not the game
|
||||
// world behind (REQ-UI-MODAL-CHROME).
|
||||
if (content.focusWidget() != nullptr)
|
||||
QWidget* focusTarget = content.getInitialFocusWidget();
|
||||
if (focusTarget == nullptr)
|
||||
{
|
||||
content.focusWidget()->setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
content.setFocus();
|
||||
focusTarget = &content;
|
||||
}
|
||||
focusTarget->setFocus();
|
||||
|
||||
// The dialog's own loop, run here rather than by QDialog::exec(), so the layer knows
|
||||
// what is open and can place it, dim behind it, and take the clicks beside it.
|
||||
|
||||
Reference in New Issue
Block a user