Skip to content

Commit

Permalink
Merge pull request #18141 from hrydgard/chat-window-close-fix
Browse files Browse the repository at this point in the history
Fix the chat window closing on pressing the X key.
  • Loading branch information
hrydgard committed Sep 12, 2023
2 parents 87a4344 + 8784ece commit 47099ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
26 changes: 16 additions & 10 deletions UI/EmuScreen.cpp
Expand Up @@ -844,21 +844,27 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
System_Notify(SystemNotification::ACTIVITY);

if (UI::IsFocusMovementEnabled()) {
bool retval = UIScreen::UnsyncKey(key);
if ((key.flags & KEY_DOWN) != 0 && UI::IsEscapeKey(key)) {
if (chatMenu_)
chatMenu_->Close();
if (chatButton_)
chatButton_->SetVisibility(UI::V_VISIBLE);
UI::EnableFocusMovement(false);
retval = true;
}
return retval;
return UIScreen::UnsyncKey(key);
}

return controlMapper_.Key(key, &pauseTrigger_);
}

bool EmuScreen::key(const KeyInput &key) {
bool retval = UIScreen::key(key);

if (!retval && (key.flags & KEY_DOWN) != 0 && UI::IsEscapeKey(key)) {
if (chatMenu_)
chatMenu_->Close();
if (chatButton_)
chatButton_->SetVisibility(UI::V_VISIBLE);
UI::EnableFocusMovement(false);
return true;
}

return retval;
}

void EmuScreen::UnsyncAxis(const AxisInput &axis) {
System_Notify(SystemNotification::ACTIVITY);
return controlMapper_.Axis(axis);
Expand Down
3 changes: 3 additions & 0 deletions UI/EmuScreen.h
Expand Up @@ -55,6 +55,9 @@ class EmuScreen : public UIScreen {
bool UnsyncKey(const KeyInput &key) override;
void UnsyncAxis(const AxisInput &axis) override;

// We also need to do some special handling of queued UI events to handle closing the chat window.
bool key(const KeyInput &key) override;

private:
void CreateViews() override;
UI::EventReturn OnDevTools(UI::EventParams &params);
Expand Down

0 comments on commit 47099ea

Please sign in to comment.