I just came back to try to solve this problem and found some hack to make it work. The hack consisted of putting an event filter in the parent Widget of the editor and accept all key presses except modifiers and other special keys. I am not exactly sure why this works but it solves the problem of some keys not being recognized by the editor. Here is the event filter I made:
Code: Select all
bool KEditorView::event(QEvent* e)
{
// HACK: when keys are pressed QEvent::ShortcutOverride is emitted. If we
// accept all the key events except for the modifiers and other special keys,
// then text will be added to the text field and shortcuts (like Ctrl+A or Ctrl+S)
// will also be enabled.
if (e->type() == QEvent::ShortcutOverride)
{
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
int key = ke->key();
// no modifiers and other special keys
if (!ke->modifiers() & (key != Qt::Key_Backspace) & (key != Qt::Key_Insert)
& (key != Qt::Key_Delete) & (key != Qt::Key_Home) & (key != Qt::Key_End)
& (key != Qt::Key_Left) & (key != Qt::Key_Up) & (key != Qt::Key_Right)
& (key != Qt::Key_Down) & (key != Qt::Key_PageUp) & (key != Qt::Key_PageDown))
{
e->accept();
}
}
return QWidget::event(e);
}
I also added a couple of screenshots comparing KTextEditor and the current editor in FreeCAD.