Allow tab / shift+tab to defocus command window.

This commit is contained in:
casey 2016-07-28 19:26:39 -07:00
parent 7dc629b4db
commit 5d9c58fd16
2 changed files with 23 additions and 15 deletions

View File

@ -92,11 +92,11 @@ cursespp::IWindowPtr MainLayout::GetFocus() {
IWindowPtr MainLayout::FocusNext() {
return (this->shortcutsFocused)
? this->shortcuts : this->layout->FocusNext();
? this->BlurShortcuts() : this->layout->FocusNext();
}
IWindowPtr MainLayout::FocusPrev() {
return (this->shortcutsFocused)
? this->shortcuts : this->layout->FocusPrev();
? this->BlurShortcuts() : this->layout->FocusPrev();
}
void MainLayout::SetMainLayout(std::shared_ptr<cursespp::LayoutBase> layout) {
@ -132,6 +132,25 @@ void MainLayout::SetMainLayout(std::shared_ptr<cursespp::LayoutBase> layout) {
}
}
cursespp::IWindowPtr MainLayout::BlurShortcuts() {
this->shortcuts->Blur();
this->shortcutsFocused = false;
if (this->layout) {
bool refocused = false;
if (this->lastFocus) {
refocused = this->layout->SetFocus(this->lastFocus);
this->lastFocus.reset();
}
if (!refocused) {
this->layout->FocusNext();
}
}
return this->layout ? this->layout->GetFocus() : IWindowPtr();
}
bool MainLayout::KeyPress(const std::string& key) {
if (prefs->GetBool(box::prefs::keys::EscFocusesShortcuts)) {
if (key == "^[" ||
@ -149,19 +168,7 @@ bool MainLayout::KeyPress(const std::string& key) {
}
}
else {
this->shortcuts->Blur();
if (this->layout) {
bool refocused = false;
if (this->lastFocus) {
refocused = this->layout->SetFocus(this->lastFocus);
this->lastFocus.reset();
}
if (!refocused) {
this->layout->FocusNext();
}
}
this->BlurShortcuts();
}
this->shortcutsFocused

View File

@ -69,6 +69,7 @@ namespace musik {
private:
void Initialize();
cursespp::IWindowPtr BlurShortcuts();
std::shared_ptr<musik::core::Preferences> prefs;
std::shared_ptr<ShortcutsWindow> shortcuts;