The primitive decorator now handles keyboard-driven movements.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2028 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2013-02-08 22:05:18 +00:00
parent 2bed00fd25
commit 1ba32a5b27
6 changed files with 60 additions and 61 deletions

View File

@@ -403,7 +403,7 @@ bool PartText::sceneEventFilter(QGraphicsItem *watched, QEvent *event) {
else if (event -> type() == QEvent::KeyRelease || event -> type() == QEvent::KeyPress) {
// Intercept F2 and escape keystrokes to focus in and out
QKeyEvent *key_event = static_cast<QKeyEvent *>(event);
if (key_event -> key() == Qt::Key_F2) {
if (!hasFocus() && key_event -> key() == Qt::Key_F2) {
setEditable(true);
QTextCursor qtc = textCursor();
qtc.setPosition(qMax(0, document()->characterCount() - 1));
@@ -411,8 +411,10 @@ bool PartText::sceneEventFilter(QGraphicsItem *watched, QEvent *event) {
} else if (hasFocus() && key_event -> key() == Qt::Key_Escape) {
endEdition();
}
sceneEvent(event); // manually deliver the event to this item
return(true); // prevent this event from being delivered to any item
if (hasFocus()) {
sceneEvent(event); // manually deliver the event to this item
return(true); // prevent this event from being delivered to any item
}
}
return(false);
}