Transfer Tab and Shift-Tab keys special handling from GuiView::event() to GuiWorkArea::event(). Add some comments.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22477 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-01-10 09:04:30 +00:00
parent f585b6ba11
commit a84fa1ce00
2 changed files with 27 additions and 15 deletions

View File

@ -574,24 +574,23 @@ bool GuiView::event(QEvent * e)
}
return QMainWindow::event(e);
}
case QEvent::ShortcutOverride: {
if (d.current_work_area_)
// Nothing special to do.
return QMainWindow::event(e);
// Allow processing of shortcuts that are allowed even when no Buffer
// is viewed.
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
if (!d.current_work_area_) {
theLyXFunc().setLyXView(this);
KeySymbol sym;
setKeySymbol(&sym, ke);
theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
e->accept();
return true;
}
if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
KeySymbol sym;
setKeySymbol(&sym, ke);
d.current_work_area_->processKeySym(sym, NoModifier);
e->accept();
return true;
}
theLyXFunc().setLyXView(this);
KeySymbol sym;
setKeySymbol(&sym, ke);
theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
e->accept();
return true;
}
default:
return QMainWindow::event(e);
}

View File

@ -510,6 +510,18 @@ bool GuiWorkArea::event(QEvent * e)
e->accept();
return true;
}
case QEvent::ShortcutOverride: {
// We catch this event in order to catch the Tab or Shift+Tab key press
// which are otherwise reserved to focus switching between controls
// within a dialog.
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
if (ke->key() != Qt::Key_Tab && ke->key() != Qt::Key_Backtab)
return QAbstractScrollArea::event(e);
keyPressEvent(ke);
return true;
}
default:
return QAbstractScrollArea::event(e);
}
@ -700,6 +712,7 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * ev)
KeySymbol sym;
setKeySymbol(&sym, ev);
processKeySym(sym, q_key_state(ev->modifiers()));
ev->accept();
}