Add QKeySequence::Backspace

Handle it in QWidgetTextControl. Add Meta(ctrl) + H
key sequence binding on Mac.

Task-number: QTBUG-32837
Change-Id: Ib1cbb2ce2e20350b4d8c72bd320dff27c1467f2b
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
bb10
Morten Johan Sørvig 2014-04-24 13:41:39 +02:00 committed by Shawn Rutledge
parent ee17adebd2
commit 791c975c55
4 changed files with 10 additions and 4 deletions

View File

@ -289,6 +289,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\row \li DeleteCompleteLine \li (none) \li (none) \li Ctrl+U \li Ctrl+U
\row \li InsertParagraphSeparator \li Enter \li Enter \li Enter \li Enter
\row \li InsertLineSeparator \li Shift+Enter \li Meta+Enter, Meta+O \li Shift+Enter \li Shift+Enter
\row \li Backspace \li (none) \li Meta+H \li (none) \li (none)
\endtable
Note that, since the key sequences used for the standard shortcuts differ
@ -679,6 +680,7 @@ static const struct {
\value AddTab Add new tab.
\value Back Navigate back.
\value Backspace Delete previous character.
\value Bold Bold text.
\value Close Close document/tab.
\value Copy Copy.

View File

@ -134,7 +134,8 @@ public:
Quit,
FullScreen,
Deselect,
DeleteCompleteLine
DeleteCompleteLine,
Backspace
};
enum SequenceFormat {

View File

@ -320,7 +320,8 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::FullScreen, 1, Qt::CTRL | Qt::Key_F11, KB_Gnome},
{QKeySequence::FullScreen, 1, Qt::Key_F11, KB_Win | KB_KDE},
{QKeySequence::Deselect, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_A, KB_X11},
{QKeySequence::DeleteCompleteLine, 0, Qt::CTRL | Qt::Key_U, KB_X11}
{QKeySequence::DeleteCompleteLine, 0, Qt::CTRL | Qt::Key_U, KB_X11},
{QKeySequence::Backspace, 0, Qt::META | Qt::Key_H, KB_Mac}
};
const uint QPlatformThemePrivate::numberOfKeyBindings = sizeof(QPlatformThemePrivate::keyBindings)/(sizeof(QKeyBinding));

View File

@ -1312,8 +1312,10 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
else if (e == QKeySequence::Delete) {
QTextCursor localCursor = cursor;
localCursor.deleteChar();
}
else if (e == QKeySequence::DeleteEndOfWord) {
} else if (e == QKeySequence::Backspace) {
QTextCursor localCursor = cursor;
localCursor.deletePreviousChar();
}else if (e == QKeySequence::DeleteEndOfWord) {
if (!cursor.hasSelection())
cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);
cursor.removeSelectedText();