diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index ec40e788c1..bb8b97d033 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -833,8 +833,10 @@ std::string PopupTextInputChoice::ValueText(bool *shadow) const { } } -LinearLayout *CreateSoftKeyboard(TextEdit *edit, bool *upperCase) { - LinearLayout *keyboard = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)); +ViewGroup *CreateSoftKeyboard(TextEdit *edit, bool *upperCase) { + ScrollView *scrollView = new ScrollView(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); + + LinearLayout *keyboard = scrollView->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT))); // TODO: Make something a bit more international... Although we don't need that for domain names. static struct { std::string_view v; const char *tag; @@ -911,7 +913,7 @@ LinearLayout *CreateSoftKeyboard(TextEdit *edit, bool *upperCase) { break; } } - return keyboard; + return scrollView; } void TextEditPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { diff --git a/Common/UI/PopupScreens.h b/Common/UI/PopupScreens.h index 4a6792d037..d9074ba934 100644 --- a/Common/UI/PopupScreens.h +++ b/Common/UI/PopupScreens.h @@ -222,7 +222,7 @@ private: bool liveUpdate_; }; -LinearLayout *CreateSoftKeyboard(TextEdit *edit, bool *upperCase); +ViewGroup *CreateSoftKeyboard(TextEdit *edit, bool *upperCase); class TextEditPopupScreen : public PopupScreen { public: @@ -243,7 +243,7 @@ private: void OnCompleted(DialogResult result) override; TextEdit *edit_ = nullptr; - LinearLayout *keyboard_ = nullptr; + ViewGroup *keyboard_ = nullptr; Choice *showKeyboardChoice_ = nullptr; std::string *value_; std::string textEditValue_; diff --git a/Common/UI/Root.cpp b/Common/UI/Root.cpp index 609fa4f6d0..4a628d0b73 100644 --- a/Common/UI/Root.cpp +++ b/Common/UI/Root.cpp @@ -414,6 +414,7 @@ DialogResult UpdateViewHierarchy(ViewGroup *root) { case NKCODE_PAGE_DOWN: MoveFocus(root, FOCUS_NEXT_PAGE); break; case NKCODE_MOVE_HOME: MoveFocus(root, FOCUS_FIRST); break; case NKCODE_MOVE_END: MoveFocus(root, FOCUS_LAST); break; + case NKCODE_TAB: MoveFocus(root, FOCUS_NEXT); break; } } } diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index 7cddbe9098..e85ab0dabc 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -40,5 +40,5 @@ private: bool promptInput_ = false; int token_; std::string messageTemp_; - UI::Button *chatButton_ = nullptr; + UI::Clickable *chatButton_ = nullptr; }; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index dbc9ef62a5..d2a3eccc3f 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -171,7 +171,6 @@ EmuScreen::EmuScreen(const Path &filename) _dbg_assert_(coreState == CORE_POWERDOWN); OnDevMenu.Handle(this, &EmuScreen::OnDevTools); - OnChatMenu.Handle(this, &EmuScreen::OnChat); // Usually, we don't want focus movement enabled on this screen, so disable on start. // Only if you open chat or dev tools do we want it to start working. @@ -663,14 +662,12 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) { // temporary workaround for hotkey its freeze the ui when open chat screen using hotkey and native keyboard is enable if (g_Config.bBypassOSKWithKeyboard) { // TODO: Make translatable. - g_OSD.Show(OSDType::MESSAGE_INFO, "Disable \"Use system native keyboard\" to use ctrl + c hotkey", 2.0f); + g_OSD.Show(OSDType::MESSAGE_INFO, "Disable \"Use system native keyboard\" to use chat hotkey", 2.0f); } else { - UI::EventParams e{}; - OnChatMenu.Trigger(e); + OpenChat(true); } } else { - UI::EventParams e{}; - OnChatMenu.Trigger(e); + OpenChat(false); } } else if (!g_Config.bEnableNetworkChat) { if (chatButton_) { @@ -861,8 +858,8 @@ void EmuScreen::ProcessVKey(VirtKey virtKey) { case VIRTKEY_OPENCHAT: if (g_Config.bEnableNetworkChat && !g_Config.bShowImDebugger) { UI::EventParams e{}; - OnChatMenu.Trigger(e); g_controlMapper.ForceReleaseVKey(VIRTKEY_OPENCHAT); + OpenChat(true); } break; @@ -1319,9 +1316,10 @@ void EmuScreen::CreateViews() { if (g_Config.iChatButtonPosition != 8) { auto n = GetI18NCategory(I18NCat::NETWORKING); AnchorLayoutParams *layoutParams = AnchorInCorner(bounds, g_Config.iChatButtonPosition, 80.0f, 50.0f); - ChoiceWithValueDisplay *btn = new ChoiceWithValueDisplay(&newChatMessages_, n->T("Chat"), layoutParams); - root_->Add(btn)->OnClick.Handle(this, &EmuScreen::OnChat); - chatButton_ = btn; + chatButton_ = root_->Add(new ChoiceWithValueDisplay(&newChatMessages_, n->T("Chat"), layoutParams)); + chatButton_->OnClick.Add([this](UI::EventParams &e) { + OpenChat(false); + }); } chatMenu_ = root_->Add(new ChatMenu(GetRequesterToken(), screenManager()->getUIContext()->GetBounds(), screenManager(), new LayoutParams(FILL_PARENT, FILL_PARENT))); chatMenu_->SetVisibility(UI::V_GONE); @@ -1407,23 +1405,23 @@ void EmuScreen::OnDevTools(UI::EventParams ¶ms) { screenManager()->push(devMenu); } -void EmuScreen::OnChat(UI::EventParams ¶ms) { +void EmuScreen::OpenChat(bool focus) { if (chatButton_ != nullptr && chatButton_->GetVisibility() == UI::V_VISIBLE) { chatButton_->SetVisibility(UI::V_GONE); } if (chatMenu_ != nullptr) { chatMenu_->SetVisibility(UI::V_VISIBLE); -#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || defined(SDL) - UI::EnableFocusMovement(true); - root_->SetDefaultFocusView(chatMenu_); + if (focus) { + UI::EnableFocusMovement(true); + root_->SetDefaultFocusView(chatMenu_); - chatMenu_->SetFocus(); - UI::View *focused = UI::GetFocusedView(); - if (focused) { - root_->SubviewFocused(focused); + chatMenu_->SetFocus(); + UI::View *focused = UI::GetFocusedView(); + if (focused) { + root_->SubviewFocused(focused); + } } -#endif } } diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 1129c1d6e9..60459ca66f 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -85,7 +85,7 @@ private: void CreateViews() override; ScreenRenderFlags RunEmulation(bool skipBufferEffects); void OnDevTools(UI::EventParams ¶ms); - void OnChat(UI::EventParams ¶ms); + void OpenChat(bool focus); void HandleFlip(); void ProcessGameBoot(const Path &filename); @@ -106,7 +106,6 @@ private: bool ShouldRunEmulation(ScreenRenderMode mode) const; UI::Event OnDevMenu; - UI::Event OnChatMenu; bool bootPending_ = true; bool bootIsReset_ = false; Path gamePath_; @@ -136,7 +135,7 @@ private: UI::Button *resumeButton_ = nullptr; UI::Button *resetButton_ = nullptr; UI::Button *backButton_ = nullptr; - UI::View *chatButton_ = nullptr; + UI::Clickable *chatButton_ = nullptr; ChatMenu *chatMenu_ = nullptr; UI::Button *cardboardDisableButton_ = nullptr;