From 57f44edaeac2c4aa7864042e00c79ebf2bdd19a0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 27 Jun 2015 09:41:53 -0700 Subject: [PATCH 1/2] Retain focus after popup choice selection. --- ui/ui_screen.cpp | 6 ++++++ ui/ui_screen.h | 1 + 2 files changed, 7 insertions(+) diff --git a/ui/ui_screen.cpp b/ui/ui_screen.cpp index 8384afee8a..984fe78665 100644 --- a/ui/ui_screen.cpp +++ b/ui/ui_screen.cpp @@ -255,6 +255,8 @@ UI::EventReturn ListPopupScreen::OnListChoice(UI::EventParams &e) { namespace UI { UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) { + restoreFocus_ = HasFocus(); + std::vector choices; for (int i = 0; i < numChoices_; i++) { choices.push_back(category_ ? category_->T(choices_[i]) : choices_[i]); @@ -288,6 +290,10 @@ void PopupMultiChoice::ChoiceCallback(int num) { e.v = this; e.a = num; OnChoice.Trigger(e); + + if (restoreFocus_) { + SetFocusedView(this); + } } } diff --git a/ui/ui_screen.h b/ui/ui_screen.h index edabf4d262..11d54caca1 100644 --- a/ui/ui_screen.h +++ b/ui/ui_screen.h @@ -218,6 +218,7 @@ private: I18NCategory *category_; ScreenManager *screenManager_; std::string valueText_; + bool restoreFocus_; }; From b72060bc062e420b4ce2320a5057b98f6298fc1b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 27 Jun 2015 09:48:24 -0700 Subject: [PATCH 2/2] Retain focus with other choice popups. --- ui/ui_screen.cpp | 18 ++++++++++++++++++ ui/ui_screen.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/ui/ui_screen.cpp b/ui/ui_screen.cpp index 984fe78665..f2b4e9cc7b 100644 --- a/ui/ui_screen.cpp +++ b/ui/ui_screen.cpp @@ -329,6 +329,8 @@ PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, flo } EventReturn PopupSliderChoice::HandleClick(EventParams &e) { + restoreFocus_ = HasFocus(); + SliderPopupScreen *popupScreen = new SliderPopupScreen(value_, minValue_, maxValue_, text_, step_); popupScreen->OnChange.Handle(this, &PopupSliderChoice::HandleChange); screenManager_->push(popupScreen); @@ -338,6 +340,10 @@ EventReturn PopupSliderChoice::HandleClick(EventParams &e) { EventReturn PopupSliderChoice::HandleChange(EventParams &e) { e.v = this; OnChange.Trigger(e); + + if (restoreFocus_) { + SetFocusedView(this); + } return EVENT_DONE; } @@ -354,6 +360,8 @@ void PopupSliderChoice::Draw(UIContext &dc) { } EventReturn PopupSliderChoiceFloat::HandleClick(EventParams &e) { + restoreFocus_ = HasFocus(); + SliderFloatPopupScreen *popupScreen = new SliderFloatPopupScreen(value_, minValue_, maxValue_, text_, step_); popupScreen->OnChange.Handle(this, &PopupSliderChoiceFloat::HandleChange); screenManager_->push(popupScreen); @@ -363,6 +371,10 @@ EventReturn PopupSliderChoiceFloat::HandleClick(EventParams &e) { EventReturn PopupSliderChoiceFloat::HandleChange(EventParams &e) { e.v = this; OnChange.Trigger(e); + + if (restoreFocus_) { + SetFocusedView(this); + } return EVENT_DONE; } @@ -453,6 +465,8 @@ PopupTextInputChoice::PopupTextInputChoice(std::string *value, const std::string } EventReturn PopupTextInputChoice::HandleClick(EventParams &e) { + restoreFocus_ = HasFocus(); + TextEditPopupScreen *popupScreen = new TextEditPopupScreen(value_, placeHolder_, text_, maxLen_); popupScreen->OnChange.Handle(this, &PopupTextInputChoice::HandleChange); screenManager_->push(popupScreen); @@ -472,6 +486,10 @@ void PopupTextInputChoice::Draw(UIContext &dc) { EventReturn PopupTextInputChoice::HandleChange(EventParams &e) { e.v = this; OnChange.Trigger(e); + + if (restoreFocus_) { + SetFocusedView(this); + } return EVENT_DONE; } diff --git a/ui/ui_screen.h b/ui/ui_screen.h index 11d54caca1..1ffb28c289 100644 --- a/ui/ui_screen.h +++ b/ui/ui_screen.h @@ -240,6 +240,7 @@ private: int maxValue_; int step_; ScreenManager *screenManager_; + bool restoreFocus_; }; class PopupSliderChoiceFloat : public Choice { @@ -259,6 +260,7 @@ private: float maxValue_; float step_; ScreenManager *screenManager_; + bool restoreFocus_; }; class PopupTextInputChoice: public Choice { @@ -277,6 +279,7 @@ private: std::string placeHolder_; std::string defaultText_; int maxLen_; + bool restoreFocus_; }; class ChoiceWithValueDisplay : public UI::Choice {