More chat code cleanup. Make the virtual keyboard in TextInputPopup scrollable.

This commit is contained in:
Henrik Rydgård
2026-03-31 16:22:24 -06:00
parent e0b75ff7e6
commit 6e073bb53f
6 changed files with 28 additions and 28 deletions
+5 -3
View File
@@ -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) {
+2 -2
View File
@@ -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_;
+1
View File
@@ -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;
}
}
}
+1 -1
View File
@@ -40,5 +40,5 @@ private:
bool promptInput_ = false;
int token_;
std::string messageTemp_;
UI::Button *chatButton_ = nullptr;
UI::Clickable *chatButton_ = nullptr;
};
+17 -19
View File
@@ -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 &params) {
screenManager()->push(devMenu);
}
void EmuScreen::OnChat(UI::EventParams &params) {
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
}
}
+2 -3
View File
@@ -85,7 +85,7 @@ private:
void CreateViews() override;
ScreenRenderFlags RunEmulation(bool skipBufferEffects);
void OnDevTools(UI::EventParams &params);
void OnChat(UI::EventParams &params);
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;