1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Remove default focus from spellbook search, allow toggling focus via shortcut

This commit is contained in:
Dydzio
2025-02-15 18:50:43 +01:00
parent 567c88a924
commit 58042c5cd6
5 changed files with 16 additions and 1 deletions

View File

@ -138,7 +138,7 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
searchBoxRectangle = std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor);
searchBoxDescription = std::make_shared<CLabel>(r.center().x, r.center().y, FONT_SMALL, ETextAlignment::CENTER, grayedColor, CGI->generaltexth->translate("vcmi.spellBook.search"));
searchBox = std::make_shared<CTextInput>(r, FONT_SMALL, ETextAlignment::CENTER, true);
searchBox = std::make_shared<CTextInput>(r, FONT_SMALL, ETextAlignment::CENTER, false);
searchBox->setCallback(std::bind(&CSpellWindow::searchInput, this));
}
@ -354,6 +354,14 @@ void CSpellWindow::fbattleSpellsb()
computeSpellsPerArea();
}
void CSpellWindow::toggleSearchBoxFocus()
{
if(searchBox != nullptr)
{
searchBox->hasFocus() ? searchBox->removeFocus() : searchBox->giveFocus();
}
}
void CSpellWindow::fmanaPtsb()
{
}
@ -546,6 +554,9 @@ void CSpellWindow::keyPressed(EShortcut key)
case EShortcut::SPELLBOOK_TAB_ADVENTURE:
fadvSpellsb();
break;
case EShortcut::SPELLBOOK_SEARCH_FOCUS:
toggleSearchBoxFocus();
break;
}
}