mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-05 18:46:18 +02:00
Merge pull request #279 from unknownbrackets/ui-focus
Retain focus after popup choice selection
This commit is contained in:
commit
bad22f7b78
2 files changed
+28
No files matched your search
@@ -255,6 +255,8 @@ UI::EventReturn ListPopupScreen::OnListChoice(UI::EventParams &e) {
|
||||
namespace UI {
|
||||
|
||||
UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) {
|
||||
restoreFocus_ = HasFocus();
|
||||
|
||||
std::vector<std::string> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,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);
|
||||
@@ -332,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;
|
||||
}
|
||||
|
||||
@@ -348,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);
|
||||
@@ -357,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;
|
||||
}
|
||||
|
||||
@@ -447,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);
|
||||
@@ -466,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -218,6 +218,7 @@ private:
|
||||
I18NCategory *category_;
|
||||
ScreenManager *screenManager_;
|
||||
std::string valueText_;
|
||||
bool restoreFocus_;
|
||||
};
|
||||
|
||||
|
||||
@@ -239,6 +240,7 @@ private:
|
||||
int maxValue_;
|
||||
int step_;
|
||||
ScreenManager *screenManager_;
|
||||
bool restoreFocus_;
|
||||
};
|
||||
|
||||
class PopupSliderChoiceFloat : public Choice {
|
||||
@@ -258,6 +260,7 @@ private:
|
||||
float maxValue_;
|
||||
float step_;
|
||||
ScreenManager *screenManager_;
|
||||
bool restoreFocus_;
|
||||
};
|
||||
|
||||
class PopupTextInputChoice: public Choice {
|
||||
@@ -276,6 +279,7 @@ private:
|
||||
std::string placeHolder_;
|
||||
std::string defaultText_;
|
||||
int maxLen_;
|
||||
bool restoreFocus_;
|
||||
};
|
||||
|
||||
class ChoiceWithValueDisplay : public UI::Choice {
|
||||
|
||||
Reference in new issue
Block a user