mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Merge pull request #21633 from hrydgard/searchfixes
Some search fixes (fixes type-to-search on Mac, fix cheat search function on iOS)
This commit is contained in:
@@ -800,7 +800,7 @@ void AskForInput(ScreenManager *screenManager, RequesterToken token, UI::View *s
|
||||
popupScreen->SetAlignTop(true);
|
||||
}
|
||||
popupScreen->OnChange.Add([callback, sourceView](EventParams &e) {
|
||||
callback(SanitizeString(StripSpaces(*(std::string *)e.v), StringRestriction::None, 0, 0), true);
|
||||
callback(SanitizeString(StripSpaces(e.s), StringRestriction::None, 0, 0), true);
|
||||
if (sourceView) {
|
||||
SetFocusedView(sourceView);
|
||||
}
|
||||
@@ -838,6 +838,7 @@ void PopupTextInputChoice::HandleClick(EventParams &e) {
|
||||
*value_ = StripSpaces(SanitizeString(*value_, restriction_, minLen_, maxLen_));
|
||||
EventParams params{};
|
||||
params.v = this;
|
||||
params.s = *value_;
|
||||
OnChange.Trigger(params);
|
||||
if (restoreFocus_) {
|
||||
SetFocusedView(this);
|
||||
@@ -949,6 +950,15 @@ ViewGroup *CreateSoftKeyboard(TextEdit *edit, SoftKeyboardState *state) {
|
||||
return scrollView;
|
||||
}
|
||||
|
||||
TextEditPopupScreen::TextEditPopupScreen(std::string *value, std::string_view placeholder, std::string_view title, int maxLen)
|
||||
: PopupScreen(title, T(I18NCat::DIALOG, "OK"), T(I18NCat::DIALOG, "Cancel")), value_(value), placeholder_(placeholder), maxLen_(maxLen) {
|
||||
if (!value_) {
|
||||
// Point it to our temporary.
|
||||
value_ = &textEditValue_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TextEditPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
UIContext &dc = *screenManager()->getUIContext();
|
||||
@@ -982,6 +992,7 @@ void TextEditPopupScreen::OnCompleted(DialogResult result) {
|
||||
*value_ = StripSpaces(edit_->GetText());
|
||||
EventParams e{};
|
||||
e.v = edit_;
|
||||
e.s = *value_;
|
||||
OnChange.Trigger(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,8 +233,7 @@ ViewGroup *CreateSoftKeyboard(TextEdit *edit, SoftKeyboardState *state);
|
||||
|
||||
class TextEditPopupScreen : public PopupScreen {
|
||||
public:
|
||||
TextEditPopupScreen(std::string *value, std::string_view placeholder, std::string_view title, int maxLen)
|
||||
: PopupScreen(title, T(I18NCat::DIALOG, "OK"), T(I18NCat::DIALOG, "Cancel")), value_(value), placeholder_(placeholder), maxLen_(maxLen) {}
|
||||
TextEditPopupScreen(std::string *value, std::string_view placeholder, std::string_view title, int maxLen);
|
||||
void CreatePopupContents(ViewGroup *parent) override;
|
||||
|
||||
const char *tag() const override { return "TextEditPopup"; }
|
||||
|
||||
+16
-2
@@ -15,8 +15,22 @@
|
||||
void Screen::focusChanged(ScreenFocusChange focusChange) {
|
||||
const char *eventName = "";
|
||||
switch (focusChange) {
|
||||
case ScreenFocusChange::FOCUS_LOST_TOP: eventName = "FOCUS_LOST_TOP"; break;
|
||||
case ScreenFocusChange::FOCUS_BECAME_TOP: eventName = "FOCUS_BECAME_TOP"; break;
|
||||
case ScreenFocusChange::FOCUS_LOST_TOP:
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
if (WantsTextInput()) {
|
||||
System_NotifyUIEvent(UIEventNotification::TEXT_LOSTFOCUS);
|
||||
}
|
||||
#endif
|
||||
eventName = "FOCUS_LOST_TOP";
|
||||
break;
|
||||
case ScreenFocusChange::FOCUS_BECAME_TOP:
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
if (WantsTextInput()) {
|
||||
System_NotifyUIEvent(UIEventNotification::TEXT_GOTFOCUS);
|
||||
}
|
||||
#endif
|
||||
eventName = "FOCUS_BECAME_TOP";
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(Log::UI, "Screen %s got %s", this->tag(), eventName);
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ public:
|
||||
virtual bool isTopLevel() const { return false; }
|
||||
|
||||
virtual TouchInput transformTouch(const TouchInput &touch) { return touch; }
|
||||
virtual bool WantsTextInput() const { return false; }
|
||||
|
||||
protected:
|
||||
int GetRequesterToken();
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
virtual UI::Margins RootMargins() const { return UI::Margins(0); }
|
||||
|
||||
virtual void focusChanged(ScreenFocusChange focusChange) override {
|
||||
Screen::focusChanged(focusChange);
|
||||
modifiersPressed_ = Modifier::NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ public:
|
||||
|
||||
const char *tag() const override { return "CwCheat"; }
|
||||
|
||||
bool WantsTextInput() const override { return true; }
|
||||
|
||||
protected:
|
||||
void BeforeCreateViews() override;
|
||||
void CreateSettingsViews(UI::ViewGroup *) override;
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
bool key(const KeyInput &touch) override;
|
||||
|
||||
bool WantsTextInput() const override { return true; }
|
||||
protected:
|
||||
ViewLayoutMode LayoutMode() const override { return ViewLayoutMode::IgnoreBottomInset; }
|
||||
|
||||
|
||||
+4
-1
@@ -325,6 +325,10 @@ void SearchBar::Draw(UIContext &dc) {
|
||||
dc.DrawText(searchFilter_, bounds_.x + leftMargin, bounds_.centerY(), 0xFFFFFFFF, ALIGN_VCENTER);
|
||||
}
|
||||
|
||||
SearchBar::SearchBar(UI::LayoutParams *params) : UI::InertView(params) {
|
||||
SetVisibility(UI::Visibility::V_GONE);
|
||||
}
|
||||
|
||||
void SearchBar::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
w = 0;
|
||||
h = 0;
|
||||
@@ -439,7 +443,6 @@ bool ViewSearch::Key(UI::ViewGroup *viewGroup, const KeyInput &input) {
|
||||
const int unichar = input.keyCode;
|
||||
if (unichar >= 0x20 && unichar != 127) { // 127 gets produced from Ctrl+Backspace on Windows for some reason.
|
||||
// TODO: Save focus state here.
|
||||
|
||||
// Insert it! (todo: do it with a string insert)
|
||||
char buf[8];
|
||||
buf[u8_wc_toutf8(buf, unichar)] = '\0';
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ void AddRotationPicker(ScreenManager *screenManager, UI::ViewGroup *parent, bool
|
||||
|
||||
class SearchBar : public UI::InertView {
|
||||
public:
|
||||
SearchBar(UI::LayoutParams *params) : UI::InertView(params) { SetVisibility(UI::Visibility::V_GONE); }
|
||||
SearchBar(UI::LayoutParams *params);
|
||||
void Draw(UIContext &dc) override;
|
||||
|
||||
bool Touch(const TouchInput &input) override;
|
||||
|
||||
Reference in New Issue
Block a user