Skip to content

Key strokes are not received anymore with the QTBUG-42183 workaround. #12

@ghost

Description

Following #11 (comment) brought to my attention that key strokes are not received anymore with the QTBUG-42183 workaround.

bool QDirect3D12Widget::event(QEvent * event)
{
switch (event->type())
{
// Workaround for https://bugreports.qt.io/browse/QTBUG-42183 to get key strokes.
// To make sure that we always have focus on the widget when we enter the rect area.
case QEvent::Enter:
case QEvent::FocusIn:
case QEvent::FocusAboutToChange:
if (::GetFocus() != m_hWnd)
{
QWidget * nativeParent = this;
while (true)
{
if (nativeParent->isWindow()) break;
QWidget * parent = nativeParent->nativeParentWidget();
if (!parent) break;
nativeParent = parent;
}
if (nativeParent && nativeParent != this &&
::GetFocus() == reinterpret_cast<HWND>(nativeParent->winId()))
::SetFocus(m_hWnd);
}
break;
case QEvent::KeyPress:
emit keyPressed((QKeyEvent *)event);
break;
case QEvent::MouseMove:
emit mouseMoved((QMouseEvent *)event);
break;
case QEvent::MouseButtonPress:
emit mouseClicked((QMouseEvent *)event);
break;
case QEvent::MouseButtonRelease:
emit mouseReleased((QMouseEvent *)event);
break;
}
return QWidget::event(event);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions