From 53bb8a6d26a0b0901fc9da680705f086ff506592 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 20 Mar 2025 20:52:50 -0500 Subject: [PATCH] focus the search field when showing --- src/dialogxml/dialogs/dialog.cpp | 8 +++++--- src/dialogxml/dialogs/strchoice.cpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 933e62941..eca659ac2 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -1158,7 +1158,7 @@ bool cDialog::hasControl(std::string id) const { } void cDialog::setDefaultButton(std::string defbtn) { - if(!hasControl(defbtn)){ + if(!defbtn.empty() && !hasControl(defbtn)){ // this is likely because the dialogxml is malformed. maybe the linter already checks this, // but the engine might as well also. throw std::string { "Requested default button does not exist: " } + defbtn; @@ -1166,8 +1166,10 @@ void cDialog::setDefaultButton(std::string defbtn) { if(!defaultButton.empty()){ getControl(defaultButton).setDefault(false); } - defaultButton = defbtn; - getControl(defaultButton).setDefault(true); + if(!defbtn.empty()){ + defaultButton = defbtn; + getControl(defaultButton).setDefault(true); + } } const char*const xBadVal::CONTENT = "$content$"; diff --git a/src/dialogxml/dialogs/strchoice.cpp b/src/dialogxml/dialogs/strchoice.cpp index 51ddf2fb6..d6e940037 100644 --- a/src/dialogxml/dialogs/strchoice.cpp +++ b/src/dialogxml/dialogs/strchoice.cpp @@ -169,6 +169,7 @@ bool cStringChoice::onOkay(cDialog& me){ bool cStringChoice::onSearch(cDialog& me){ if(!search_open){ me["search-field"].show(); + me.setFocus(&(dynamic_cast(me.getControl("search-field")))); me["search-label"].show(); me["reverse"].show(); me.setDefaultButton("search");