Fixed Return and Enter being treated as different keys on Mac OS (#6729)

Co-authored-by: Chad Gorman <nevicar@Chads-Mini.localdomain>
Reviewed-by: Mm2PL <mm2pl+gh@kotmisia.pl>
This commit is contained in:
Nevicar
2026-01-10 07:37:13 -07:00
committed by GitHub
parent af573484c4
commit 0549b42ec0
6 changed files with 111 additions and 9 deletions
+14
View File
@@ -12,6 +12,8 @@
#include "controllers/hotkeys/HotkeyHelpers.hpp"
#include "ui_EditHotkeyDialog.h"
#include <QSignalBlocker>
namespace chatterino {
EditHotkeyDialog::EditHotkeyDialog(const std::shared_ptr<Hotkey> hotkey,
@@ -21,6 +23,18 @@ EditHotkeyDialog::EditHotkeyDialog(const std::shared_ptr<Hotkey> hotkey,
, data_(hotkey)
{
this->ui_->setupUi(this);
// normalize Key_Enter (numpad) to Key_Return so both Enter keys display and behave identically
QObject::connect(
this->ui_->keyComboEdit, &QKeySequenceEdit::keySequenceChanged, this,
[this](const QKeySequence &keySequence) {
auto normalized = normalizeKeySequence(keySequence);
if (normalized != keySequence)
{
// Block signals to prevent infinite loop
QSignalBlocker blocker(this->ui_->keyComboEdit);
this->ui_->keyComboEdit->setKeySequence(normalized);
}
});
this->setStyleSheet(R"(QToolTip {
padding: 2px;
background-color: #333333;
@@ -8,6 +8,7 @@
#include "common/QLogging.hpp"
#include "controllers/hotkeys/Hotkey.hpp"
#include "controllers/hotkeys/HotkeyController.hpp"
#include "controllers/hotkeys/HotkeyHelpers.hpp"
#include "controllers/hotkeys/HotkeyModel.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/dialogs/EditHotkeyDialog.hpp"
@@ -18,6 +19,7 @@
#include <QKeySequenceEdit>
#include <QLabel>
#include <QMessageBox>
#include <QSignalBlocker>
#include <QTableView>
#include <array>
@@ -94,8 +96,16 @@ KeyboardSettingsPage::KeyboardSettingsPage()
auto *searchText = new QLabel("Search keybind:", this);
QObject::connect(keySequenceInput, &QKeySequenceEdit::keySequenceChanged,
[view](const QKeySequence &keySequence) {
view->filterSearchResultsHotkey(keySequence);
this,
[view, keySequenceInput](const QKeySequence &keySequence) {
// Normalize Key_Enter (numpad) to Key_Return for consistent search
auto normalized = normalizeKeySequence(keySequence);
if (normalized != keySequence)
{
QSignalBlocker blocker(keySequenceInput);
keySequenceInput->setKeySequence(normalized);
}
view->filterSearchResultsHotkey(normalized);
});
view->addCustomButton(searchText);
view->addCustomButton(keySequenceInput);