keyboard: Make key buttons work

Not sure whether this is the right way...
This commit is contained in:
Peter Hartmann 2018-03-27 19:00:43 +02:00
parent ddea04445c
commit 60c16c82c8
2 changed files with 5 additions and 0 deletions

View File

@ -258,8 +258,11 @@ void QskInputCompositionModel::moveCursor( Qt::Key key )
if ( !m_data->preedit.isEmpty() ) if ( !m_data->preedit.isEmpty() )
return; return;
// ### this should be in the panel:
QKeyEvent moveCursorPress( QEvent::KeyPress, key, Qt::NoModifier ); QKeyEvent moveCursorPress( QEvent::KeyPress, key, Qt::NoModifier );
QKeyEvent moveCursorRelease( QEvent::KeyRelease, key, Qt::NoModifier ); QKeyEvent moveCursorRelease( QEvent::KeyRelease, key, Qt::NoModifier );
QFocusEvent focusIn( QEvent::FocusIn ); // hack to display the cursor
QCoreApplication::sendEvent( m_data->inputItem, &focusIn );
QCoreApplication::sendEvent( m_data->inputItem, &moveCursorPress ); QCoreApplication::sendEvent( m_data->inputItem, &moveCursorPress );
QCoreApplication::sendEvent( m_data->inputItem, &moveCursorRelease ); QCoreApplication::sendEvent( m_data->inputItem, &moveCursorRelease );
} }

View File

@ -160,6 +160,8 @@ QskKeyButton::QskKeyButton( int keyIndex, QskInputPanel* inputPanel, QQuickItem*
options.setFontSizeMode( QskTextOptions::VerticalFit ); options.setFontSizeMode( QskTextOptions::VerticalFit );
setTextOptions( options ); setTextOptions( options );
setFocusPolicy( Qt::TabFocus );
auto keyData = m_inputPanel->keyDataAt( m_keyIndex ); auto keyData = m_inputPanel->keyDataAt( m_keyIndex );
const auto key = keyData.key & ~KeyStates; const auto key = keyData.key & ~KeyStates;