mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-08 12:16:17 -04:00
UI: Refocus top document automatically
This commit is contained in:
@@ -66,9 +66,6 @@ Popup::Popup() : Document(kDocumentSource), mRoot(mDocument->GetElementById("pop
|
||||
Document::hide(mPendingClose);
|
||||
}
|
||||
});
|
||||
|
||||
// We start hidden, but want focus for an open nav event
|
||||
mDocument->Focus();
|
||||
}
|
||||
|
||||
void Popup::show() {
|
||||
|
||||
@@ -87,9 +87,21 @@ void update() noexcept {
|
||||
for (const auto& doc : sDocuments) {
|
||||
doc->update();
|
||||
}
|
||||
|
||||
// Remove closed documents
|
||||
const auto [first, last] =
|
||||
std::ranges::remove_if(sDocuments, [](const auto& doc) { return doc->closed(); });
|
||||
sDocuments.erase(first, last);
|
||||
|
||||
// If no documents have focus, explicitly focus the top one
|
||||
if (auto* context = aurora::rmlui::get_context();
|
||||
context != nullptr && context->GetFocusElement() == nullptr)
|
||||
{
|
||||
if (auto* top = top_document()) {
|
||||
top->focus();
|
||||
}
|
||||
}
|
||||
|
||||
sync_input_block();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user