Fix backspace on qt osx

pull/3/head
Li Linfeng 2019-08-12 19:03:46 +08:00 committed by Hleb Valoshka
parent 7713f8b610
commit 2c92aee13a
1 changed files with 13 additions and 1 deletions

View File

@ -430,7 +430,19 @@ void CelestiaGlWidget::keyPressEvent( QKeyEvent* e )
{
if ((e->text() != 0) && (e->text() != ""))
{
appCore->charEntered(e->text().toUtf8().data(), modifiers);
QString input = e->text();
#ifdef __APPLE__
// Taken from the macOS project
if (input.length() == 1)
{
QChar c = input.at(0);
if (c == 0x7f /* NSDeleteCharacter */)
input.replace(0, 1, 0x08 /* NSBackspaceCharacter */); // delete = backspace
else if (c == 0x19 /* NSBackTabCharacter */)
input.replace(0, 1, 0x7f /* NSDeleteCharacter */);
}
#endif
appCore->charEntered(input.toUtf8().data(), modifiers);
}
}
}