From b72060bc062e420b4ce2320a5057b98f6298fc1b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 27 Jun 2015 09:48:24 -0700 Subject: [PATCH] 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 984fe7866..f2b4e9cc7 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 11d54caca..1ffb28c28 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 {