focus the search field when showing

This commit is contained in:
2025-03-20 20:52:50 -05:00
parent f26a9e9c32
commit 53bb8a6d26
2 changed files with 6 additions and 3 deletions

View File

@@ -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$";

View File

@@ -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<cTextField&>(me.getControl("search-field"))));
me["search-label"].show();
me["reverse"].show();
me.setDefaultButton("search");